How to prompt browser to display open/save dialog box using jquery?
+1
A:
Not possible. The browsers handle that specifically so that hackers can't force you to download a virus, which would be much easier for them if it happened in javascript.
Sarfraz
2010-04-16 06:55:27
@sarfraz any other possibilty to do it in asp.net?
bala3569
2010-04-16 06:56:49
@bala3569: asp.net is server-side language, it can not interact directly with the browsers. So I am sorry there is no chance in that either.
Sarfraz
2010-04-16 06:57:47
A:
$(document).bind('keydown', function(e){
switch(e.which){
case 83:{
if(e.ctrlKey){
var prompt = 0;//confirm('save?');
if(!prompt){
e.preventDefault();
e.stopPropagation();
return(false);
}
}
}
}
});
This code will block the ctrl+s shortcut. I didn't figure out why confirm() and alert() destroy this mechanism. But you should be able to create a custom confirmation dialog!
Should work.
Kind Regards
--Andy
jAndy
2010-04-16 07:51:04
A:
What I've done in situations such as this is open an invisible iFrame on the page using javascript, which opens a page with the apprepriate HTTP headers:
Content-Disposition: attachment; filename=genome.jpeg;
naturally change "genome.jpg" to the appropriate default filename.
Jared Forsyth
2010-04-16 14:51:33