Solved

How to disable Back,Forward button, etc in a Web browser

Posted on 2002-04-11
31
4,677 Views
Last Modified: 2012-06-21
How to disable Back,Forward button, etc in a Web browser thru Javascript?

Also, pls tell how to avoid the web page to be saved?

How to disable View Source option?
0
Comment
Question by:Ebron
  • 11
  • 6
  • 4
  • +5
31 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 50 total points
ID: 6933893
You cannot disable those options on the users browser.  You can open a new window with the buttons nt showing but the fucntions are ther and 99% of users know how to get to them.  If you could do it, it would just irritate users and they would not return to your site.  If you explain what you are trying to do, that you think you need to disable everything, maybe we can give you alternatives.

Cd&
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6933907
iam sorry for you man; really sorry; ;-)

ya most of the things you asked cannot be done;




lexxwern
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6933989
U can not do it ......

But one siggestion...

If u open that page in new window with no toolbar and
other properties disabled and disable the right click on that page you can prevent user to perform those functions.

just an ieda....

happy programming..

TP
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6934012
Tejas,

>>>you can prevent user to perform those functions.
Just how do you think that prevents them from doing anything?  Shift+f10 still gives them the context menu and the backspace key is still available.  All that does is irritate the user, it does not fool anyone, and all the functionality is still there.
Cd&
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6934333
Continuing from where cd& left

Alt + <left> ............... Back
Alt + <right>............... Forward



lexxwern
0
 
LVL 2

Expert Comment

by:coreyit
ID: 6934485
Oh, you can do all of these. Just right your own client software that only allows navigation from the web page, destroys every downloaded resource immediately after displaying it, and has no view source option.

As for existing clients, you're out of luck.

>>>you can prevent user to perform those functions.
COBOLdinosaur, you've previously posted a little script line that can be pasted into the IE address bar that will display the source too. I love that one :)

-corey
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6934513
You mean:

javascript:str=document.documentElement.innerHTML;document.write('<textarea rows=20 cols=60>'+str+'</textarea>');


Cd&
0
 
LVL 2

Expert Comment

by:coreyit
ID: 6934570
Yes, that's the one. There was a period not too long ago when it seemed like every other javascript question related to disabling source views etc. I remember that line being a nice close to a long chain of "don't bothers."

cheers :)
0
 
LVL 1

Expert Comment

by:tonejunkie
ID: 6936608
You can't disable the buttons, but you can try this:

1)  Spawn a window without the buttons.  Then write an even handler that will intercept every event and check for keystrokes that do the same thing as back/forward buttons.  These would be:  Alt+left arror, Alt+right arrow, Backspace.  And return false when those occur.

or you can:

2)  If users goes from page A to page B, and you don't want them going back to A.  In A add a redirection call to B.  You can also turn off page caching using meta tags.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6936697
tonejunkie, and how so you prevent me from turning off active scripting so none of that works?  Or from loading the page directly in the address bar?  

Cd&
0
 
LVL 1

Expert Comment

by:tonejunkie
ID: 6936901
COBOLdinosaur, if JavaScript is disabled in the user's browser then this question doesn't belong in the JavaScript section.  :)

I'm going on the assumption that JavaScript is enabled.

As far as loading directly in the address bar.. I'm not sure, but there might be a way to tell where the page is loaded from (who the parent is).  If it's not loaded from the right place, don't let the user view the page.  I dunno, that's just crazyness at this point.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6937023
>>>that's just crazyness at this point

Exactly, anything that tries to mess with the controls limit options, interfere with the users right leads to craziness.  

In general the sources for these kinds of questions are  amateurs who do not understand the technology(including designers); and developers from GUI environments where they are used to having control of the client.  There is only one one to do this with more than 5% reliability, and that is to write your own browser and then convince user to use a browser that limits there right to navigate as they choose, and treats them like children.  

Cd&

0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6940051
absolutely true Cd&;

people generally try to mess around with what the visitor can do; well their efforts should be directed not towards this but towards what the site can do, so Ebron if your site does something good for the visitors, they will not press the back button; put more effort to achieve this and not disabling back.

good day,


lexxwern
0
 

Expert Comment

by:gaurav_b123
ID: 6941160
see u can not restrict user from  moving back and front ......
but u can disable view source by opening a small pdf file in a very very small section of window.......
use two frames and in one frame open any small pdf and find it urself.......try it........
0
 
LVL 2

Expert Comment

by:coreyit
ID: 6942761
gaurav_b123, if you'd post a site using the technique that you mention, I'd be happy to post their source here for you.

-corey
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6942781
You beat me to it Corey, I was giong to post the same challenge.

Except I was going to have my 9 year niece email it them after. That is how easy it is. <G>

Cd&
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6942824
WONDERING what is pdf's special property that when it displays in a frame itll block the whole code from being viewed but not getting loaded?


gourav was this a joke?
0
 
LVL 2

Expert Comment

by:coreyit
ID: 6942851
LOL!

You can be certain that I would choose your nine year old niece to build my website over anyone that told me they could keep people from viewing the source... and I'm sure that's not giving her nearly enough credit.

-corey
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6947739
This script will disable the back button from keyboard
<HTML>
<HEAD>
<script>
function checkShortcut()
{
          //alert(event.keyCode);
        if(event.keyCode==8 || event.keyCode==13)
        {
              return false;
        }
}
</script>
</HEAD>
<body onkeydown="return checkShortcut()">
Test
</HTML>

This script will disable shift+F10 button
<html>
<head>
<title>Javascript split function</title>
<script language="javascript">
function test(){
window.showModalDialog("http://www.msn.com","Dialog Arguments Value","dialogHeight: 500px;

dialogWidth: 500px; dialogTop: 288px; dialogLeft: 209px; edge: Sunken; center: Yes; help:

Yes; resizable: No; status: No;");
}
</script>
</head>
<body>

<form name="frm" action="" method="post">
<input type="button" name="showModalDialog" value="showModalDialog" onclick="test()">
</form>
</body>
</html>


Waiting for comments...

T.P.
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6947753
Note : window.showModalDialog is IE specific

T.P.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6947781
If you want it to work you'll need to fix the javasscript run time error first.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6947909
BTW the back button still works on that page. It does not work on the modal page, but when a popup gets stuck in my face I follow the following sequence:

Close the popup.
hit back or X
add the site to my list of sites that I will not visit because they do not respect my rights.

Cd&
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6948232
Yo need to put the script to disable the back button on the pop up page . I think I do not need to mention it to u.

what kind of run time error u r getting please specify.

The page we want to generate the only purpose is to do not give the right to end user. So the owner of the site really
don't care ....if he intend to do so.. the script is applicable to the page where it needed the functionality
not on the whole site.

The question was how to disable the back button and myscript does it in a way...again it's just an ieda as I mentioned in my first comment.

BUT IT CAN BE DONE.

T.P.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6948292
TP,

I think it was just the way EE formatted it.  I cut and pasted it and the line with the showModalDialog had a couple of line breaks in it.  It was okay when I removed them.

As for the method of diabling, when you launch a new window there is no history to go back to anyway.

Generally this kind of question comes for some amateur who thinks they have discovered some thing special, and giving them a bunch of hacks just encourages the growth of trash on the Internet.

Cd&
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6948451
Happy Programming!!!!

T.P.
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6984477
Ebron...

please reply,

T.P.
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8123650
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or so. I appreciate any comments that would help me to make a recommendation.
 
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
 
ahosang
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8128353
The answer is you can't.  I said so in the first response to the thread.  Most of what follows is noise.  So points to me IMHO.

Cd&
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8239765
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

points to COBOLdinosaur
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8303722
per recommendation (now where did I put that button that grades an F? <diabolical laughter>)

SpideyMod
Community Support Moderator @Experts Exchange
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8306614
oh F ...  10 times point value ... F = FFFFFFFFFFFabulous solution!

Thanks Spidey. :^)

Cd&
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now