Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi.
I want to restrict user by saving web page(by pressing Ctrl + S) I have used below javascript code for same.

JavaScript
$(window).bind('keydown', 'ctrl+s', function () {
      $('#save').click(); return false;
  });

This functionality works fine for ie browser but it has some issue in Mozilla & chrome , On Mozilla & chrome web browser , user can save web page(by Ctrl + S from keyboard) keeping mouse cursor on address bar. How can I restrict user by saving web page?

[Note : already added code to restrict user by saving webpage using menubar & contextmenu]
Posted
Updated 27-Dec-13 0:08am
v3

i dont know about restricting user to save page from address bar.
your code works perfectly for webpage.

i have found little bug.
what if user right click on your page and click on save as..
for that use :-
<body oncontextmenu="return(false);">

as per my knowledge:-
you can't prevent your site from being downloaded, because that is what every user's browser is doing to display it.
The other option is to try and make it more difficult or annoying for them to download it, by using JavaScript to change the behavior of the mouse buttons.

in I.E. you can download your page using menu->file->save as..
 
Share this answer
 
Comments
niravsahayata 27-Dec-13 5:38am    
I am opening browser window with no toolbar & no menubar option , so user can not save using file options, also I have already restrict context menu on my page.
Refer:-http://stackoverflow.com/questions/16161521/how-to-restrict-file-from-downloading-by-end-user[^]
C#
function checkButton(){
    if(event.button != 1){
        document.oncontextmenu=new Function ("return false") ;
        //if NS6
        if (window.sidebar){
            document.oncontextmenu=disableselect
        }
    }
}


This may help


[Edit member="Tadit"]
Link text added to reflect the Article/QA title.
[/Edit]
 
Share this answer
 
v3
Comments
King Fisher 27-Dec-13 5:12am    
is this related to the Question
niravsahayata 27-Dec-13 5:36am    
As I have mention in question , user should not allow to save web page(by Ctrl + S from keyboard) keeping mouse cursor on address bar , your answer doesn't satisfy this , its still not work for firefox & chrome also I have already handled context-menu stuff just want solution for keyboard event.
Gitanjali Singh 27-Dec-13 5:48am    
Got your point,working on the same, will update soon.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900