0

I am trying to implement CTRL+s event to pop up "save as" window in browser when I click on button. But it's not working. Please suggest how can I save complete webpage when user click on button. Below is the code:

$( '#save_as' ).bind( "click", function() { var e = jQuery.Event( "keypress", { which: 115, ctrlKey:true} ); jQuery(window).trigger( e ); alert("Ctrl-S pressed !!!"); }); 
3
  • AFAIK you can't open Save as dialog in javascript. Commented Feb 17, 2016 at 8:20
  • any reference related to save as dialog? Commented Feb 17, 2016 at 8:31
  • @LinkinTED the problem is not generating the keypress. See the link in my other comment Commented Feb 17, 2016 at 9:53

1 Answer 1

-1

It works! Look at a live example: http://codesheet.org/codesheet/346fJMrz

(function($){ $(document).ready(function(){ $(window).keypress(function(event) { if (!(event.which == 115 && event.ctrlKey) && !(event.which == 19)) return true; setTimeout(function() { alert('Ctrl + s is pressed'); //$("#safeformbtn").click(); //click some button.... //$("#postform form input[name=submit]").click(); //click some button.... }, 200); event.preventDefault(); return false; }); }); })(jQuery); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.