Debt Consolidation - Jigsaw Puzzles - Loans - Skype - Credit Cards

PDA

View Full Version : How do I Javascript redirect without Javascript?


johnsmith153
May 14th 2008, 6:49 am
I want to show a php page with heavy php code.

After all php processing is done, it then:

1. Uses <noscript> in the <head> to check if js on or not - if so, no problem
2. If not, will show this on screen:

Javascript not on

Turn on then click here / or, click to view basic version of our site (js not needed)

What I need to do is, if js is not on, then prevent the page from viewing, including all my echo php commands that are in the body tag below.

Originally I had an idea to automatically redirect to a nojavascript.html page - but cant as I have no js to do a location.href.

I need (1) a way to redirect without js OR
(2) A way to prevent showing page if js is not on

Oh, I don't use loads of unnecessary js, but I use DHTML/AJAX a lot so would look strange and not have any useability.

xrvel
May 14th 2008, 7:07 am
My idea is, put files in separated directories (althought it seems "redundant" somewhat).

For example, create "/with-js" dir, with all files that are supposed to be viewed with js.

And create "/without-js" dir

Now, lets move to the upper dir, lets create a welcome page (splash screen, you can name it :D), for example an "index.php"

So here's the scenario.
Visitors go to "something.com/index.php" and see the welcome page.
If the JS is on, s/he must visit the "something.com/with-js".
If it is off, s/he must visit the "something.com/without-js".

Ok now the question is how to redirect visitors, based on the JS setting.
Lets go to index.php


<script>
function lets_check() {
document.getElementById('clicked').href = './with-js';
}
</script>
<body onload="lets_check()">

<h1>Welcome Here</h1>

<a href="./without-js" id="clicker">Click here to continue</a>
</body>

johnsmith153
May 14th 2008, 7:24 am
Thanks for the idea, but I have just thought of an even better way. I have tested and works brilliantly.

<noscript>
<meta http-equiv="Refresh" content="0; URL=http://www.turn-it-on-for-gods-sake.com" />
</noscript>