nova7foldism
nova7foldism

Reputation: 41

How to disable "save page as" using javascript?

How can I disable the "save page as" on popup menu and file menu in a web browser ?

Upvotes: 3

Views: 10523

Answers (3)

Alnitak
Alnitak

Reputation: 339786

You can't.

Well, technically you could disable right-click (context) menus completely by trapping window.oncontextmenu which in jQuery is as trivial as:

$(window).bind('contextmenu', false);

but you shouldn't because it'll just annoy your users and they'll still be able to use the File->Save Page As... menu.

Upvotes: 6

hakre
hakre

Reputation: 197682

You can't, but there is actually a technical way to prevent file savings of your website via javascript. However it has a lot of problems, but it's simple to explain:

After your webpage's HTML has been transferred from the server into the browser, a javascript routine takes care to extend the contents of the document about the technical file-size limit of the system the browser is running on.

When the user wants to save the file, the file-system will give an error in the moment the file-size maximum limit has been triggered.

However as before the file-saving action will come into place, most often such scripts hit the memory limit of the browser already. That means, you actually already prevent the user from saving the page because the browser denies to handle it any longer. Either by giving a warning message or by just crashing.

So it depends a bit how far you want to go.

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1038730

You can't mess-up with the client browser settings in javascript without his permissions.

Upvotes: 8

Related Questions