automatically press keyboard keys with jQuery - javascript

Here is a button whenever it's clicked. Automatically keybord keys are pressed ctrl+shift+p.
This is actually window print shortcut key.How can I do that. Because when window.print() function is used in google chrome. chrome show chrome print dialog box. but I want window print dialog and this is the shortcut key of window print dialog.

You can disable the default behavior of chrome print box. May be you can refer this link for that
http://ryan.mcgeary.org/2012/09/13/disable-chrome-print-dialog-use-osx-instead/
This will serve well for you but If you are looking something to do it globally for all the users then you may have to go through some other option... Will try to find an alternate for that as well.
Hope this be of some help
Happy Learning

Related

Default popup no working when pressing the extension icon [duplicate]

I'm making a Chrome Extension and need to view the HTML/CSS/JS of the popup.html.
I can't right click to inspect elements. Is there another way? I need to make sure CSS and JavaScript is being inserted correctly. How to debug a problem in that popup file?
Right click the extension's button, then 'Inspect Popup'
Inspect Popup has gone away with the latest build.
Here's how I debug Chrome Extension Popups.
Click your popup button to see the webpage (the popup window itself).
Right-click in the window and select Inspect element
The Chrome Debugger window comes up with the right context, but you've already missed your breakpoints and debugger statements.
HERE'S THE TRICK. Click on the Console part of the debugger and type: location.reload(true) and press enter.
Now your breakpoints are hit! Great way to reload changed scripts without revisiting the Extension page.
Perhaps another way may be to find the ID: for your application in chrome://chrome/extensions/
You can then load your popup in a regular window by
chrome-extension://id_of_your_application/popup.html
Exchange popup.html for the file you have specified in manifest.json under "default_popup" property.
Yes, 'Inspect Popup' on the extension icon, and apart from that - from extension manager you can also inspect your options page.
Try switching Auto-open DevTools for popups in the bottom right of DevTools Settings:
Another good way to inspect Javascript being part of the extension popup is adding special comments to the end of the script to be debugged:
// #sourceURL=popup.js
This is de-facto a directive for DevTools to include this specific file into Sources tab. From there you can inspect code, add breakpoints, output to console, etc. as usual.

Simulate keyboard press in javascript

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

Scripts not running in FF and Chrome

I am using javascript alert message to show validation messages. In Firefox and Chrome first time working fine,second time for same alert same its asking message like "Prevent this page from creating additional dialogs" with check box. After select that check box, Next time button click scripts not executing. How to block that message?
Use a JavaScript Modal popup! eg. JQuery UI Modal Popup
This is a browser matter, so you as a developer cant do anything with that behavior.
Here is a similar question
already answered here
unfortunately you can't be sure that user has his browser settings with javascript alerts popup on ( that called with 'alert('...') function').
You should use javascript dialog plygin instead.
For example:
http://fancybox.net/
its a browser property for the client,if he doesnt want to view these alerts. you cant remove that check box and message.
if this message is shown then what the problem, leave it for the user.
why you want to force him to view these alerts,
it must be user's wish to see or not see these alerts.
for better user experience and for your purpose you can use fancybox or facebox
fancy box fiddler check this http://jsfiddle.net/BJNYr/

Use System Print Dialog in Chrome in JavaScript

We have an issue where Chrome's "Print Preview" does not print our pages correctly. If you use the "Use System Print Dialog link" (Ctrl+Shift+P), it prints our page fine (almost identically to Firefox).
We have a button on our page that calls window.print() to open the print dialog. However, in Chrome it opens to the "Print Preview" dialog which ends up not printing our page correctly.
Is there away with JavaScript to print directly to the "system print dialog" in Chrome?
P.S.
I do know how the end user can disable the Print Preview in chrome://flags, but what I want to know is there anyway to prevent it from showing when I programmatically call window.print() (or similar) regardless of user settings.
Print dialogs are not scriptable using JavaScript. They're proprietary parts of browsers themselves.
Hi i am facing the same issue... I even tried firing keyboard event ctrl+shift+P from my script in order to show system print dialog.
You can fire a keyboard event and that issue is successfully dispatched, however the value of keyCode that the browser receives is always 0 (instead of ASCII value of ‘P’)
There is a bug logged https://bugs.webkit.org/show_bug.cgi?id=16735 against webkit for the same… and here are some posts http://code.google.com/p/chromium/issues/detail?id=27048, http://code.google.com/p/chromium/issues/detail?id=52408 mentioning the same issue in Safari and Chrome…

See what (javascript) function is used when you press a button

Let's say you have a button and a javascript function onclick. Is it possible in (for example with Firebug) to see which javascript is called and how the script looks like when you click this button?
I know how to place a breakpoint, but then you have to search it by yourself.
select it is possible (excet for some advanced scenarios - for instance with SharePoint Ribbon).
you can use FF Firebug or IE 8+ Dev Toolbar. in IE you need to press F12 button on a keyboard "select element" (arrow-like button in a top left corner of a tool ) and then pick your button on the page.

Categories