experchange > javascript

David T. Smith (11-17-03, 10:51 PM)
I've been working with a page that should act as a 'jump page' before
loading a PDF and when I use the location.replace function to replace
the jump page with the resulting PDF, both the jump page and the pdf
show up into the browser history (in IE only) leading to the dreaded
back-button loop.

My first bit of javascript (to load the jump page) is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<p><a href="testjump.html"> Next PDF</a></p>
</body>
</html>

The jump page is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<script type="text/javascript" language="JavaScript" >
//<!--
window.location.replace("http://www.adobe.com/products/postscript/pdfs/wp_oce.pdf");
//-->
</script>
</body>
</html>

Thanks in advance

DTS
Thomas 'PointedEars' Lahn (11-22-03, 09:49 PM)
David T. Smith wrote:
> I've been working with a page that should act as a 'jump page' before
> loading a PDF and when I use the location.replace function to replace
> the jump page with the resulting PDF, both the jump page and the pdf
> show up into the browser history (in IE only) leading to the dreaded
> back-button loop.


That shows again that client-side actions are not suited for redirection.
Use server-side redirection instead which does not break the Back button,
as the W3C recommends:



> My first bit of javascript (to load the jump page) is:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> </head>
> <body>
> <p><a href="testjump.html"> Next PDF</a></p>
> </body>
> </html>


There is no JavaScript at all contained in the above source.

> The jump page is:
> [...]
> window.location.replace("http://www.adobe.com/products/postscript/pdfs/wp_oce.pdf");
> //-->
> [...]


That is in fact JavaScript code, depending on host objects of the UA's
DOM. But have you ever thought of users that UA does not provide this
object? (Obviously not, since you are not testing them before accessing
them.) And, on the other hand, have your ever thought of users having
no support for client-side JavaScript or have it disabled/restricted?

Again, what you are looking for is a server-side solution.

PointedEars
Similar Threads