Click to See Complete Forum and Search --> : Using the <noscript> tag


DJRobThaMan
08-08-2003, 03:03 PM
Hi,

So, it's possible to use javascript to preload a website:

<script>
var i =0;
function load(){
images[i] = newArray();
images[i].src = "image" + i + ".src";
++i;
if(i == some number){
document.location = home page;
}
</script>
<body onload="load()">....


but not everybody has javascript enabled, which would mean that they wouldn't ever see the site (unless i threw in a link in the body i guess).

So my question is, is there a way that I could do this so everybody could have the page preloaded.

I've seen that you can use the <noscript> tag to kind of make the browswers that don't have javascript enabled to pretend like they do (i think, don't quote me on that one) or at least do some things that javascript can.

Thanks

kdcgrohl
08-08-2003, 07:42 PM
Hmmm...

Well, you could load your images in a hidden div, and you could tell the other page to load with a meta refresh, only problem is, I can't think of a way to tell when the images are done loading to fire the meta refresh. In other words, I don't know...

Exuro
08-08-2003, 10:33 PM
The <noscript> tag doesn't make browsers without JavaScript "pretend" they have it. In JavaScript enabled browsers, anything inside the <noscript></noscript> tags is simply ignored. It's almost like commenting something out. However, if the browser does not support JavaScript then it reads and displays the code inside the tags.

So, let's say that you had a dynamic menu on your site that was only displayed through JavaScript. If the user was not using JavaScript, they'd be in some big trouble because they couldn't use the menu, and therefore couldn't navigate the site. This is where <noscript> comes in... What you'd do is have an alternate menu for users without JavaScript support inside those tags. If the user had JavaScript support, then the regular menu is shown, and if not, then the alternate "noscript" menu is shown.

Since there's not really any way to preload images without JavaScript (at least not that I can think of), what I'd do if I were you is just include a meta refresh to re-direct non JavaScript users inside a <noscript>.

Well, hope that helps!