I would like to ask, if there is a possibility to simulate more keypresses at once using javascript.
My problem is, that I have a window which is blocked to be closed, but for administration purposes I need to close it sometimes using some kind of hack, unfortunately chrome disables javascript to close current tab if it wasn't created by javascript.
So one thing came to my mind and it is to simulate pressing CTRL+W in javascript which will close current tab and I will be able to leave chrome.
I am using --kiosk to keep user without any other options to close the window.
So my idea was to have an input which in case that I will put e.g. 123 inside it will simulate the action of keyboard.
Is this even possible, or do any of you guys have any better solution?
Thanks in advance!
Jakub
Related
This is a bit of an odd question, but basically, I'm trying to display different pop-up menus to a user depending on how they click my browser action button (the icon to the right of the Omnibar). One way that I thought of doing this is by detecting whether the user is clicking it normally or holding shift as they click it. Is this possible?
If there is no way of doing this, I would appreciate any suggestions as to how to display different menus to the user with a single browser action button. I would rather not make the user select from two options in the actual pop-up window - a single button press would be preferable.
Thanks
Edit: I'm thinking the best way to do this may be to check for the Shift key being pressed using Javascript as soon as the pop-up window is displayed, then display a menu according to that. I'm going to try that and report back.
I've tried for 2 hours, but didn't find a solution, too.
I think it's not possible to capture the click event, which opened the popup.
I am using window.open() method to open a page as a pop-up window for a link button click event.
But the poup-up window is having minimize,maximize,close(x) button.
I dont want those buttons. How can remove these buttons?
This is the method i am using,
window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=no,scrollbars=1,resizable=0,width=450,height=310,left=500,top=350");
Tell me how can do this.
Regards,
Chirag Jain.
You can't.
If you want a popup style window without full window decorations you'd have to create a new overlay <div> on top of the existing content and fill that with content, perhaps using an <iframe>.
You can't do it from javascript alone. Think about it, if you could, then people could put it into code on web-pages and cause other people's computers to open windows they couldn't easily close.
Instead you'll have to look for an answer specific to whichever browser you're using to host this application, and change it on the computers of your users appropriately. Even then though I don't think you'll be in luck (with Firefox for example, I can see how to get rid of them on all browser windows, but not on just one).
I know there is a very similiar question (JavaScript: How to select "Cancel" by default in confirm box?) on this site, but I felt like I did not get a good answer out of that one as my premises are not the same.
Problem description: I am writing a web browser Javascript popup window that is supposed to take some information as input and the user can choose between "OK" to process the information and continue with whatever, or "Cancel" to close the window and go back to whatever. So far so good. The problem is that some users press "X" in the upper right corner of the popup to close the window (either by mistake or actually believing that the data is processed) and get a second dialog popup (you cannot change the text in this dialog) displaying "Are you sure you want to navigate away from this page?" - "Press OK to continue, or Cancel to stay on the current page" - OK/Cancel... Now, some of the users just press enter on their keyboard and oops, the popup is closed and all information is lost.
Question: Can you, or is there a workaround to set focus on "Cancel" instead of "OK" when it comes to the dialog of whether to close an Internet Explorer popup/tab or not?
Thank you in advance! =)
Unfortunately, I don't think it's possible to change focus on browser-generated dialog boxes.
As Deestan suggested, maybe you can create a faux popup using js and css, and do whatever you want in terms of styling it, and still have the user enter information, and have the information passed to your code.
From what i've heard/read, it's generally accepted that using alert() or popup() for anything other than debugging is frowned upon.
There are some video streaming sites that pop up an ad anytime you click anywhere on the page. The problem is, you have to click on the page to press play! So I was thinking of making a UserScript that disables the script that does this. The only problem is, I already disable all the scripts on the site and when I do it still pops up. Is there a way that I can disable them ? I'm also using jQuery, so if I can do it through their interface, that would be great.
edit: Two perfect examples of such sites are daclips.in and gorrilavid.in
I have Adblocker Plus, and it seems like it is not recognizing "on Click" events as pop-ups, rather normal clicked links. And the logic is simple, no Adblocker will block you from clicking something intentionally and it (the link) opening in another window/tab.
The problem is the new window contains your clicked Url, while the original window/tab "Refreshes" (i.e. redirects) to another url.
Advertising companies seem to use this trick to bypass adblocking software.
Just ditch Chrome and use Firefox. Firefox already have built-in mouse-click popups. I think all addons like Adguard or Adblock can not disable mouse-click popups. If you use Firefox, these are the steps:
Type about:config in the browser's address bar and hit the enter key.
First time users need to confirm that they be careful on the next page.
Type or paste dom.popup_allowed_events into the search field.
The value of the preference highlights all events that are allowed to spawn popups.
Edit the value to remove some or all of the items here.
Why not just use a browser extension such as AdBlock?
https://chrome.google.com/webstore/detail/adblock/gighmmpiobklfepjocnamgkkbiglidom?hl=en
My go-to is right click and open in new tab. onClick events only happen with a left click. It's cumbersome but it still ends up being less work than closing the pop-up and whatever annoying prompts it may have.
I do not there's a practical solution for this.
Moreover, I think some of the answers here are missing the specific case in OP, where clicking anywhere on the page will cause the pop up to happen, not just clicking on links. According to this, neither right-clicking then choosing "open", nor noticing and blocking the target URL will help. I do not know of an add blocker that helps here either, because it's not trivial to meaningfully filter a click event that is taking place on the whole page object.
Only the solution provided by #Monkey would work, at the drawback of possibly breaking other things.
I am trying to allow my CMS users to click certain controls with ALT+CTRL both pressed, but this results in the context menu being shown, because CTRL+Leftclick simulates a Rightclick, at least here on Mac OSX (which is the primary OS of my client).
The question is: how can I stop the context menu from popping up but still make sure my click goes through to the element it is being triggered on?
I tried oncontextmenu="return false;" in my <body> for testing purposes. It would properly prevent the menu from popping up, but my click event would not go through.
As i was unable to properly solve this problem by fiddling around with the way the browser behaves in regard to the context menu, i went for a different approach and bound the META key instead of the CTRL key. Works well this way. I'll leave the q/a in for others.