View Full Version : noscript tag

07-01-2011, 09:50 PM
So I was going to comment on another thread that was up a few days ago, but it is resolved and figured best to not repost on it anyways (can you repost on a resolved thread?)
anyways... it was this (http://www.codingforums.com/showthread.php?t=230745) thread and as rnd_me said the <noscript> tag is only supposed to be used in the body. So the reason I began thinking of this is because I am coding asp.net and using a master page. I cannot have <head> tags in the child pages because they get their <head> tags from the master... so i ran into the issue of redirecting clients if they do/do not have js enabled. the problem is if i use a script in the <head> on the master page and then the children get it, everytime a user clicks a link to goto a page they will be redirected to the default js page (script that redirects will be placed on every page). So I am playing around with how to do this the easiest and thought of that thread and thought, well if my default page is the "js enabled page" then i can put the noscript tag in the body and it will redirect users to the non js page and then i no longer have to worry about using the script in the <head> tags... am I making sense? upon further thought though you can put <script> tags anywhere, it is just generally placed in the <head> <-- this is an accurate statement correct?....
so i guess my question/reason for this post is to get feedback... i think it might be a "6, half-dozen the other" situation and just pend on "my style" but do you guys feel (keep in mind that this has to be done outside the <head> tag and inside the <body> tag) it is better to have default page be for script disabled and have a <script> which redirects, or the default page be js enabled and use the <noscript> tag? I guess it would come down to which one processes quicker? any thoughts on this would be great- I feel i have an answer (well two) but wanted feedback on which is better (and preferably a reason as to why one is better eg speed or something)... also if anyone reading could correct me if I am thinking incorrectly about this whole matter that would be great too

07-02-2011, 02:59 AM
As old pedant said "Usually, this is done the other way around: You have a non-JS landing page. If JS is enabled you immediately redirect the user to the JS-rich page." If you do it that way you don't even really have to redirect anyone. JS either works or it doesn't. Which is the way you're meant to be doing it. Essentially you'll be going to more effort purely to do it the wrong way. http://www.onlinetools.org/articles/unobtrusivejavascript/

07-05-2011, 07:07 PM
yeah i get that- but you have to take into consideration that i have no <head> tags... these are "pre written" via my master page... so I cannot embed a nice one line script in my head tag or my pages would be thrown into an infinite loop.. so because of this the script needs to be placed in the body- and that is fine- but because i have to place it in the body anyways, i could essentially use the <noscript> tags... I guess a more efficient question is, when are the noscript tags used? or are they going to be gone soon or what? what is the performance hit from doing a script redirect and a noscript redirect? is it an issue with browser rendering? ie all browsers see the script redirect but not all render the noscript tags?
... I guess my main "issue" with doing it the "normal way" is that now i am adding more hops to the user- a large majority of users will have js enabled, so why redirect them?
...idk i may be nit picking on a pointless topic, but if there is anyone who knows a legit reason why one is prefered that would be great. Or some example of why you would use the <noscript> tags and how it does not apply to my situation...
to reitterate, my entire <head></head> region is inherited from another page, so the issue of using <noscript> in the body is not an issue, and (if I am understanding this correctly) the typical js redirect that is in the head (all nice and tidy) is now going to have to be in the body