Disabling Your Browser`s Back Button

advertisement
C o m p u t i n g
B a s i c s
How Did They Do That?
Compiled by Helen Bradley
Graphics & Design by Ginger R. Riley
Disabling Your
Browser’s Back Button
visiting the Sausage software site (http://www
TBackry.sausage.com)
and, once it’s loaded, press your browser’s
button. Is something funny happening? Probably. You’ll
find your Back button appears to be disabled; pressing it takes
you back to the Sausage software site and not to the site you
came from.
This effective disabling of the browser’s back button is not
limited to Sausage.com and it happens on a number of sites.
Caught In The Loop
he trick is done using a
TSausage
redirection page on the
software site.
Sausage.com is a site that
uses frames and instead of
loading the page you’re
viewing right now, a redirection page loads first.
To the right is the code of
the redirection page. It’s
called Main_redirect.html
and its purpose is to load
the file Main.html in the
main frame.
So, when you visit
Sausage.com, the top and
side frames and a large
main frame for the content
are created. The file
Main_redirect.html is
loaded in the main frame.
It immediately loads the
file Main.html. You probably won’t even notice that
one page is loading another because it happens
so quickly.
When you’re viewing
Main.html and you press
your Browser’s back button
you are taken back one page
to the page Main_redirect
.html, which was the page
loaded immediately before
Main.html. Now the purpose of Main_redirect.html
is to load Main.html. Once
this happens, you’re back
where you started and what
you see on your screen is
unchanged.
There are multiple ways of doing this and we look at some
of them using the Sausage.com as an example.
There is no method provided in either Netscape Navigator
or Microsoft Internet Explorer to program the browser’s Back
button. The result is that people create their own workarounds and the effects you see on the Web vary according to
what the particular site designer wanted to achieve.
Step 1
Type www.sausage.com
or click a link to that site
from your home page.
Entering this URL
loads the page
Main_redirect.html
which loads the
Main.html page.
Step 2
Step 4
Main-direct.html loads
Main.html so quickly you
don't see what has happened
Step 3
When you press your browser’s Back
button, Main_direct.html loads.
C o m p u t i n g
Remove The Button
sites remove the
Sso ome
Back button entirely
that the user can’t use
it; this is usually done
for security purposes.
For example, you may
find this on a banking
site. This can be easily
achieved with some
JavaScript code, which
opens the page in a new
window that doesn’t
have any of the standard
B a s i c s
buttons. If you rightclick the page you’ll still
be able to move back,
but hiding the back
button is deemed to be a
reasonable protection.
[This site opens its online banking screen in a
full screen buttonless
window. However, rightclicking the page still gives
the user access to the Back
option.]
Buttonless Window Code
his code extracted from the
TReference
Netscape Online JavaScript
manual (http://devel
oper.netscape.com/docs/manuals
/communicator/jsref/index.htm)
creates a button on a form which,
when your user clicks it, opens a
second, small browser window
which doesn't have a toolbar on it.
Because the Back button is one of
the toolbar buttons, it too is missing
from this window. You can try this
yourself by creating a small dummy
file called Sesame.html and testing it
out.
Don’t Come Back
ther designers don’t
O
want you to be able
to get back to a previously
loaded page. Again, this
can be done with some
simple JavaScript code
which opens a new page
but doesn’t add the current page’s details to the
history list so you can’t
get Back to it. The trick is
to use location.replace()
rather than the more
usual location.href =
assignment.
Add this code to the
Body of a document and
create a file called newpage.htm. Click the button
to load newpage.htm and
notice that you can’t return to the page with the
button on it by pressing
the Back button.
Download