DOM window.top.location

V

Vince Morgan

Hi All,
I beleive [window.top.location] is part of the HTML DOM.
The reason I ask is that if it does work I'll structure my no javascript
fallback arrangement like below.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
window.top.location="MyJavaPage.html";
</script>
</head>
<body onLoad="window.top.location='NoJavaPage.html';" id="main" class="">
<p></p>
</body>
</html>

If it doesn't, I'm quite lost as to how to achieve a graceful fallback.
I know I could just let it fall through and have the non-JS enabled content
within the body. However, for the sake of speed, and that the JS enabled
page should actualy be the default, I would prefer to do it as above or
similar.
Any comments or help is very much appreciated.
TIA,
Vince Morgan
 
V

Vince Morgan

<body onLoad="window.top.location='NoJavaPage.html';" id="main" class="">

Please excuse the 'id' & 'class' within the body tag.
It was cut from some rubbish code with too much haste :)
Vince Morgan
 
J

Jonathan N. Little

Vince said:
Hi All,
I beleive [window.top.location] is part of the HTML DOM.
The reason I ask is that if it does work I'll structure my no javascript
fallback arrangement like below.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
window.top.location="MyJavaPage.html";
</script>
</head>
<body onLoad="window.top.location='NoJavaPage.html';" id="main" class="">

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That's JavaScript between the two quotes! It will not work if JavaScript
is disabled
<p></p>
</body>
</html>

If it doesn't, I'm quite lost as to how to achieve a graceful fallback.
I know I could just let it fall through and have the non-JS enabled content
within the body. However, for the sake of speed, and that the JS enabled
page should actualy be the default, I would prefer to do it as above or
similar.
Any comments or help is very much appreciated.

The only way I can see it to make this page the non-JavaScript page and
use JavaScript function to change to the JavaScript page, that way the
page will only be redirected *if* JavaScript is enabled.
 
V

Vince Morgan

Jonathan N. Little said:
class="">

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That's JavaScript between the two quotes! It will not work if JavaScript
is disabled

The only way I can see it to make this page the non-JavaScript page and
use JavaScript function to change to the JavaScript page, that way the
page will only be redirected *if* JavaScript is enabled.

Thank you very much Jonathan.
I think your idea is a good one. However, I couldn't find a way for the
non-JS page not to show prior to the redirection.
There is another way though. One that allows for a very small switchboard
type page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Refresh" content="0; url=Non-JS-Page.html">
<script type="text/javascript">
window.top.location="JS-Page.html";
</script>
</head>
<body>
<p></p>
</body>
</html>

I don't have enough knowledge about <meta>, or any html for that matter, to
know if the above will work in most browsers.
My previous programming experience is with languages that are lower level
and strictly standardised so I'm finding it a bit difficult following all
the incompatibilities in browsers.
Having said that, do you see any serious issues with the above code?
Thank you again Jonathan,
Vince
 
V

Vince Morgan

Previously I posted about sending and recieving data without having to
re-transmit the entire page.
You (Jonathan) offered a php solution that works well, however it does,
naturaly, send back an entire page.
In fact that solution is now running fine on the company's server.
I couldn't help continuing my search for a solution that didn't require
re-transmition of the page itself, and I found one.
My thinking was along the lines of an activex type page, and that is where
'XMLHttpRequest' was originaly implemented apparently.
'XMLHttpRequest' allows for the transmision of data back to the client
without having to send the entire page.
So far my limited testing has shown it to be very quick, and it seems to be
quite widely supported too.
I thought you may find it interesting, and perhaps usefull.
Thank you again Jonathan,
Regards,
Vince
 
J

Jonathan N. Little

Vince said:
Thank you very much Jonathan.
I think your idea is a good one. However, I couldn't find a way for the
non-JS page not to show prior to the redirection.
There is another way though. One that allows for a very small switchboard
type page.

Then you are not really disabling JavaScript.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Refresh" content="0; url=Non-JS-Page.html">
^^^
I believe on meta refresh the content must be a non-zero value.
<script type="text/javascript">
window.top.location="JS-Page.html";
</script>
</head>
<body>
<p></p>
</body>
</html>

I don't have enough knowledge about <meta>, or any html for that matter, to
know if the above will work in most browsers.
My previous programming experience is with languages that are lower level
and strictly standardised so I'm finding it a bit difficult following all
the incompatibilities in browsers.
Having said that, do you see any serious issues with the above code?

Look, with page non-js.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Non-JavaScript Page</title>

<script type="text/javascript">
window.top.location="js-page.html";
</script>

</head>
<body>
<p>This is the Non-JavaScript Page, no redirect will occur if JavaScript
is disabled</p>
</body>
</html>

And js.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>JavaScript Page</title>
</head>
<body>
<p>This is the JavaScript Page, you will only reach here is JavaScript
is enabled</p>
</body>
</html>

So the logic flow is:

Call the Non-JavaScript page which as the JavaScript function
JavaScript is enable?
YES, then JavaScript function redirects bowser to JavaScript page
NO, then no redirection occurs and the Non-JavaScript page remains
 
N

Neredbojias

To further the education of mankind, "Vince Morgan"
Thank you very much Jonathan.
I think your idea is a good one. However, I couldn't find a way for
the non-JS page not to show prior to the redirection.

Do a document.write to style, say, the body of the non-j/s page invisible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top