...

View Full Version : make document/ website viewable only when JavaScript is enabled



Taro
02-28-2012, 11:26 PM
Hello,

I would like to know how to make a website (in this case, a parent div) viewable only if JavaScript is enabled?

I tried to develop a code that can do this, but could not find the solution.


<html>
<head>
<script type="text/javascript">
window.onload=function()
var="true"
if(JavaScript.enabled)
{
document.getElementById('true')
}
OnClick()
{document.getElementById('toggle').onclick=function()
{document.getElementById('jahava').style.display=(document.getElementById('jahava').style.display!=' none')?'none':'';}}
</script>
</head>
<body>
<noscript>You must have JavaScript enabled to view the website.</noscript>
<div id="jahava">Contents Here</div>
</body>
</html>

:eek:

Old Pedant
02-28-2012, 11:39 PM
Making it way too hard.



<html>
<body>
<div id="nojs">Sorry, you can't view this page if JavaScript isn't enabled</div>
<div id="contents" style="display: none;">
... your normal contents here ...
</div>
<script type="text/javascript">
document.getElementById("nojs").style.display = "none";
document.getElementById("contents").style.display = "block";
</script>
</body>
</html>

If JavaScript isn't available and enabled, then the "contents' will never get displayed. But the "nojs" will.

rnd me
02-29-2012, 06:56 PM
i use css for this:


<html>
<head>
<style> .nojs #jahava {display:none;} </style>
</head>
<body class="nojs" onload='document.body.className="loaded" '>
<noscript>You must have JavaScript enabled to view the website.</noscript>
<div id="jahava">Contents Here</div>
</body>
</html>

jalarie
03-02-2012, 03:49 PM
Making it way too hard.
Just to cover all bases, what if CSS is also disabled?

VIPStephan
03-02-2012, 04:03 PM
Write the entire DOM with JavaScript. :rolleyes:

rnd me
03-02-2012, 09:03 PM
Just to cover all bases, what if CSS is also disabled?

fine.


<head>

<script type='text/javascript'>document.write("<st"+"yle>"); </script>
<meta http-equiv="refresh" content="0;url=http://google.com/">
<style></style>

</head>


patent pending hack of mine...



or, use my crypto app (http://danml.com/pub/crypto.htm), but hard-code the password by defining a PW string var of the password:

<html> <script>PW="defaultPassword"; eval( unescape( "function%20jcipher%28p%2Cs%29%7Bvar%20i%3D0%2CP%3D0%2CK%3D0%2Cb%3D%22%22%2CMax%3D0%2Cd%3D%5B%5D%3Bif %28p.slice%280%2C3%29%3D%3D%22zz%2C%22%29%7Bvar%20slen%3Ds.length+1%3Bd%3Dp.split%28%22%2C%22%29%3Bp %3D%22%22%3Bvar%20junk%3Dd.shift%28%29%2CScc%3DString.fromCharCode%3BMax%3Dd.length%3Bvar%20tr%3D%5B Max%5D%3Bfor%28var%20i%3D0%3Bi%3CMax%3Bi++%29%7BP%3Dd%5Bi%5D%3BK%3Ds.charCodeAt%28i%25slen%29%3Btr%5 Bi%5D%3DScc%28P%5EK%29%3B%7Dreturn%20tr.join%28%22%22%29%3B%7Dreturn%20false%3B%7D%0A" ) );
var enc='zz,44 ,0,10,13,26,64,126,90,40,83,4,24,26,30,0,32,8,12,13,4,85,24,27,112,10,29,28,0,79,26,11,119,68,17,9,6 5,24,13,31,53,65 ,18,83,0,10,16,23,105,16,0,70,73,28,2,84,36,9,26,0,87,12,19,23,101,72,69,7,65,5,13,6,53,15,7,83,19,6 ,4,77,32,18 ,12,3,22,20,14,24,53,65,28,29,27,22,82,13,102,68,47,7,23,20,63,23,34,8,3,7,87,6,1,68,101,10,4,4,13,1 6,8,75,90,107 ,58,83,3,29,27,1,100,68,17,9,65,17,9,2,53,13,28,3,87,14,82,7,111,0,0,70,21,29,13,0,112,2,18,29,87,11 ,29,68,116,12 ,12,21,77,85,14,1,36,65,16,28,2,3,22,68,110,11,17,70,7,28,2,16,112,21,27,22,87,28,29,8,117,16,12,9,1 5,91'
if (typeof PW == 'undefined'){var PW = prompt('Enter The Password for this Document:')};
if (PW.length){ document.write( jcipher(enc, PW)); };
</script></html>

(changes from generated output in red). i made this a document to demo, but you can place that script bock into the parent div to conceal only part of a document.
this works with css, works with meta refresh blocking, and requires js to even read the source by any human.

felgall
03-02-2012, 09:39 PM
There isn't really any purpose served by trying to obfuscate the code since the final HTML that it generates is easy to view regardless using either one of the development tools or a simple piece of JavaScript.

There also isn't really any reason for preventing those who have JavaScript disabled from accessing the page unless you are just too lazy to create a version of the page that will work for everyone. If you do want to drive those without JavaScript away from your page along with their friends and their friends then a simple "Go Away you are not welcome here" message in place of the content of your site will effectively produce the same end result (except slightly quicker).

It is unlikely that anyone with CSS disabled will have JavaScript enabled. It is far more likely that someone will override your CSS and/or JavaScript with their own.

You should only use document.write if you need to support Netscape 4 and earlier (although even by the time Netscape 4 was released it was considered extremely poor practice to have pages that don't work when JavaScript isn't available).

The only sites where it makes sense to have pages that actually rely on JavaScript to work are those on sites that are actually about JavaScript and anyone visiting a site about JavaScript with JavaScript disabled or not available in their browser at all wouldn't be expecting all the script examples to work in their browser.

Apart from animations, anything that can be done with JavaScript can also be done without it and the reason why a large number of people actually disable JavaScript is because they visit too many sites that have annoying animations.

Those who don't have JavaScript enabled can be divided into two groups - those who are using a browser without JavaScript who therefore can't turn it on and those who have deliberately disabled it for a reason and who therefore will NOT turn it on just because some site owner was too lazy to set up their site properly to work without it.

You may get away with a JavaScript only site if it is only intended for you and a few friends to use but you certainly can't get away with it for a business site (as one retailer discovered after being fined several million for not having a site that worked without JavaScript and which was therefore found to be discriminating against disabled people).

Philip M
03-03-2012, 09:57 AM
:D


You may get away with a JavaScript only site if it is only intended for you and a few friends to use but you certainly can't get away with it for a business site (as one retailer discovered after being fined several million for not having a site that worked without JavaScript and which was therefore found to be discriminating against disabled people).

An urban myth, surely! If you can prove this, please supply a reference. I doubt that even in enlightened Australia it is a criminal offence to have a site which does not work without Javascript.

When I Google for "Javascript discrimination" I get many links that tell me that I must have Javascript enabled to view them! :) Including The Gay and Lesbian Rights Lobby. :D

Edit: Researching, I find that in 2000, an Australian blind man won a court case against the Sydney Organizing Committee of the Olympic Games (SOCOG). This was the first successful case under Disability Discrimination Act 1992 because SOCOG had failed to make their official website, Sydney Olympic Games, adequately accessible to blind users. Presumably he went on to sue book and newspaper publishers on the same grounds! :D I rather think that Javascript or lack of it was not an issue in this case. I suspect that he was not totally blind, but visually impaired, perhaps colour-blind.

IMHO people who deliberately disable Javascript in their browsers (a tiny minority surely?) must know perfectly well what they are doing, and should be prepared to accept the consequences. Same with those who insist on clinging to Netscape 4! If I disable Javascript in my browser that does not somehow make me disabled.

felgall
03-03-2012, 11:10 PM
An urban myth, surely

It was one of the big department stores in the USA sued by a blind person who was unable to use their site to make purchases because the site required JavaScript and the site was impossible to navigate with JavaScript enabled if you couldn't actually see the site. It was settled out of court for some undisclosed amount that is believed to be in the hundreds of thousands or millions. The store web site was also quickly changed so it would work for blind people so as to prevent a recurrence. It happened about two or three years ago.

The Gay and Lesbian Rights Lobby is not a business and so would not be subject to the rules regarding preventing people with disabilities from being allowed to buy products from them.

Studies have shown that over 70% of web users are disabled in some way although most of the disabilities are so minor that they can be compensated for by simple things such as zooming pages to make the text big enough to read or overriding the stylesheet with one that doesn't use the colours that the person cannot distinguish between.

Somewhere between 6 and 10% of web users have JavaScript disabled. In some cases it is because the browser or web reader being used doesn't support JavaScript. More common perhaps is all the people who have got fed up with ad after ad after ad after ad and silly animation after silly animation and who have therefore deliberately turned it off to get rid of all the garbage. The more knowledgeable of those have their browser set so that JavaScript is only enabled on those sites they regularly visit where the script actually serves a useful purpose (this the statistics show they have it disabled but they actually have it enabled for some sites).

You can get away with a site that doesn't work without JavaScript providing that you are not a business selling to the public. For a business there is the risk of being sued (assuming that the people without JavaScript along with their friends and their friend's friends don't simply switch to buying from the competition. For other sites requiring JavaScript simply means that you have instantly lost at least 6% of potential visitors and possibly several times that (depending on how many friends those who can't use the site have and how widely the message that the site is a heap of excrement actually spreads). After all for almost any web site there are dozens of alternative sites some of which will work without JavaScript that everyone can use instead of the one that is broken for some visitors.

MancunianMacca
03-03-2012, 11:57 PM
This post is redundent as I read the above one :P How can I delete my posts?

rnd me
03-04-2012, 01:42 AM
You may get away with a JavaScript only site if it is only intended for you and a few friends to use but you certainly can't get away with it for a business site (as one retailer discovered after being fined several million for not having a site that worked without JavaScript and which was therefore found to be discriminating against disabled people).

disabled people can run javascript. javascript greatly enhances accessibility and it's cousin usability. If a site is inaccessible, it's usually because of image text, plugins, and poor dom structure (lack of <Hx>s, <nav>, <img alt>, role=, or using <meta refresh=0>, etc).

now let me be clear: it is possible to reduce accessibility with javascript. many widgets are not keyboard-navigable as are navs that use jQuery().hover(), client-side redirects, harsh validation, and others gotchas.


That being said, as far as content goes, ajax injecting new static content is just as or more accessible than "regular" pages. <video> pumping captions to a div for screen-reader announcement is far more accessible than flash captions inside a black-box. ARIA form and control states provide a lot more info to AT than CSS, but they need javascript to be updated after page-load. Often, javascript is used to replace plug-ins with poor accessibility, and that's a clear win for accessibility.


Just like HTML, javascript is a tool that can build something accessible or inaccessible, it depends on how it's used. There is nothing intrinsically inaccessible about javascript itself.

webdev1958
03-04-2012, 01:59 AM
You may get away with a JavaScript only site if it is only intended for you and a few friends to use but you certainly can't get away with it for a business site

Well, that is interesting because either:

1) You are telling a blatant lie.

or

2) You are displaying your incompetancy by not getting your facts straight first before posting

or

3) My legal adviser at the ATO has been lying to me when he informed me that I am under no legal obligation to provide full functionality to javascript disabled browsers and that I am not liable in any way to users with javascript disabled.

I seem to recall that you made similar comments/generalisations on another website. I have sent a copy of your posts, name and contact details to my legal adviser and asked him to investigate if what you say is true for my particular case and if not, to take what ever legal action he feels is appropriate.

VIPStephan
03-04-2012, 03:16 AM
Look whoís chiming in! Long time, no see, bullant. ;)

Anyway, in response to Philip Mís opinion:



IMHO people who deliberately disable Javascript in their browsers (a tiny minority surely?) must know perfectly well what they are doing, and should be prepared to accept the consequences. Same with those who insist on clinging to Netscape 4! If I disable Javascript in my browser that does not somehow make me disabled.

I have several minor websites registered with a free StatCounter account which is logging a maximum of 500 hits. On the currently most popular site of these, of the 500 hits it shows 9 without JavaScript. On the other sites it shows between 0 and 7 hits out of 500 without JS. I installed a new one recently with just 72 hits and there are 7 without JS.

OK, it might be very low in percentage, and hits are not equal to unique visitors (one visitor can make several hits, or several hits can come from one visitor only, respectively) but shows that itís certainly possible that people browse without JS. I donít see any reason to exclude them, especially when itís not a lot of additional effort to provide proper accessibility.

webdev1958
03-04-2012, 03:25 AM
I donít see any reason to exclude them, especially when itís not a lot of additional effort to provide proper accessibility.

Only if the client is willing to pay for the additional work. If they aren't, I am under no obligation, legal or otherwise, to provide it.

felgall
03-04-2012, 07:53 AM
Only if the client is willing to pay for the additional work. If they aren't, I am under no obligation, legal or otherwise, to provide it.


If they are not prepared to pay the extra then why put the extra effort in to creating the JavaScript version. The version that works without JavaScript is always much easier to build - just not as quick and convenient for those with JavaScript enabled to use.

Only where the client is prepared to pay for the extra effort should you be creating the JavaScript version. There is no legal obligation to create a web page at all. There is a legal obligation in some countries for business sites to ensure their site is usable for ALL their visitors. Mostly it is a matter of wanting people to actually visit the site and so you build it so that it functions for all visitors because that's the best way to avoid getting a reputation for creating garbage web sites.

The only web site known to have been actually sued for it not working without JavaScript was the US store that settled out of court for a sum believed to be somewhere between 100,000 and 10,000,000. All other sites that require JavaScript usually just have everyone ignore that site and go to their competition instead. No one ever hears about them because no one bothers to visit them.

There are also lots of people writing garbage that they think is JavaScript that actually makes the site harder to use - that's why so many people disable JavaScript. If all the JavaScript were actually written properly then there'd be no reason for anyone to disable it. It takes several years for even an experienced programmer to learn how to write JavaScript properly so most of what is written is better suited to Netscape 2 than it is to modern browsers.

Just consider how much supposed JavaScript you see that contains any of the following long dead code:

language="javascript"
document.write
document.all
eval
alert
prompt
navigator.userAgent

any of those is a clear sign that the person who wrote the code has not learnt JavaScript but has just copied something that someone else wrote over 10 years ago.

Anyway, your legal advisor can't force people to visit crap web sites so their opinion is irrelevant.

webdev1958
03-04-2012, 09:31 AM
There is a legal obligation in some countries for business sites to ensure their site is usable for ALL their visitors.

Now you are watering down the false statement you made earlier and on other websites.

If you feel you have been defamed or slandered by me labelling you a blatant liar and/or an incompetant fool on other websites (people can make up their own minds) and using copies of your posts as proof then feel free to show some courage for a change and sue me. But when I have issued that challenge to liars in the past they have always run off holding their tails between their legs and I can give you a 100% guarantee you will do the same because I am under no obligation, legal or otherwise, to provide full functionality for javascript disabled browsers in contrast to what you have posted here and elsewhere.

You are not even remotely qualified to give me legal advice as you have attempted in the past and your "legal advice" is at best total garbage and at worst blatant cowardly lies in my particular circumstances.

This matter is now out of my hands as I posted earlier :)

Philip M
03-04-2012, 10:26 AM
The only web site known to have been actually sued for it not working without JavaScript was the US store that settled out of court for a sum believed to be somewhere between 100,000 and 10,000,000.

To be candid, I do not believe this. Please point me to an authoritative reference.

Philip M
03-04-2012, 10:34 AM
Now you are watering down the false statement you made earlier and on other websites.

If you feel you have been defamed or slandered by me labelling you a blatant liar and/or an incompetant fool on other websites (people can make up their own minds) and using copies of your posts as proof then feel free to show some courage for a change and sue me. But when I have issued that challenge to liars in the past they have always run off holding their tails between their legs and I can give you a 100% guarantee you will do the same because I am under no obligation, legal or otherwise, to provide full functionality for javascript disabled browsers in contrast to what you have posted here and elsewhere.

You are not even remotely qualified to give me legal advice as you have attempted in the past and your "legal advice" is at best total garbage and at worst blatant cowardly lies in my particular circumstances.

This matter is now out of my hands as I posted earlier :)


I wish to register a public protest at the intemperate language used by webdev1958, who is clearly the reincarnation of the univerally despised and banned member bullant.
bullant was banned for threatening legal action against a moderator. But he had accumulated many infractions for abusive language before that.
Anyone who rants on in this manner is in my view close to being as mad as a box of frogs.

I call on the moderators to get rid of webdev1958. His attitude, language and sheer rudeness mean that he is not a fit and proper person to be a member of the forum.

If others agree, please use the "Report this post" button and send the mods a suitable short message.

webdev1958
03-04-2012, 11:03 AM
What's the issue here?

If someone tells me lies or lies about me as felgall has, are you saying that I am not allowed to highlight those lies, along with copies of their posts as proof, and expose the people who made them as liars wherever I like?

If so, then you are in effect condoning allowing members to post lies about other members.

MancunianMacca
03-04-2012, 11:07 AM
Just consider how much supposed JavaScript you see that contains any of the following long dead code:

language="javascript"
document.write
document.all
eval
alert
prompt
navigator.userAgent



Prompt is not "dead" it's used alot in websites. Isn't it?

MancunianMacca
03-04-2012, 11:14 AM
What's the issue here?

If someone tells me lies or lies about me as felgall has, are you saying that I am not allowed to highlight those lies, along with copies of their posts as proof, and expose the people who made them as liars wherever I like?

If so, then you are in effect condoning allowing members to post lies about other members.

No, because your intention is to "troll" and to the thread you are not providing any useful information, but you are bashing a member who has helped me on many occasions with his coding. If it's wrong what he said then he made a mistake, he is certainly not "incompetent" so just back off.

Philip M
03-04-2012, 11:16 AM
Prompt is not "dead" it's used alot in websites. Isn't it?

No, not in any website which purports to be professional.

But I would advise you not to box outside your own (very low) weight band. Otherwise webdev1958 will start to vomit over you as well.

MancunianMacca
03-04-2012, 11:19 AM
No, not in any website which purports to be professional.

But I would advise you not to box outside your own (very low) weight band. Otherwise webdev1958 will start to vomit over you as well.

I don't know what you mean, weight band? Nevermind you added some to get it to make sense.

And I don't really care for internet trolls. They just ammuse me. They are not really doing anything but showing us they have no life.

webdev1958
03-04-2012, 11:23 AM
No, because your intention is to "troll" and to the thread you are not providing any useful information, but you are bashing a member who has helped me on many occasions with his coding. If it's wrong what he said then he made a mistake, he is certainly not "incompetent" so just back off.

How is a member posting lies about me, like felgall has, not trolling then?

The "legal advice" felgall has posted to me in the past has been totally false and when challenged to provide evidence supporting his "advice" he has failed to do so on each occasion. He has done it on far too many occasions for me to consider it a "mistake", as you put it, and that is why I eventually passed on his name and contact details to my legal adviser at the ATO for investigation because it is impossible for both felgall and my legal advider to be telling me the truth. Clearly, one of them is lying and since felgall has never backed up his advice with supporting evidence then I am choosing to believe my legal advider is the one telling me the truth, regarding my situation, and hence felgall is not. :)

Philip M
03-04-2012, 11:25 AM
I don't know what you mean, weight band? Nevermind you added some to get it to make sense.

And I don't really care for internet trolls. They just ammuse me. They are not really doing anything but showing us they have no life.

Boxers compete in weight bands. A flyweight does not fight with a heavyweight. If he did he might get badly hurt.

MancunianMacca
03-04-2012, 11:26 AM
How is a member posting lies about me, like felgall has, not trolling then?

The "legal advice" felgall has posted to me in the past has been totally false and when challenged to provide evidence supporting his "advice" he has failed to do so on each occasion. He has done it on far too many occasions for me to consider it a "mistake", as you put it, and that is why I eventually passed on his name and contact details to my legal adviser at the ATO for investigation because it is impossible for both felgall and my legal advider to be telling me the truth. Clearly, one of them is lying and since felgall has never backed up his advice with supporting evidence then I am choosing to believe my legal advider is the one telling me the truth, regarding my situation, and hence felgall is not. :)

Well i'm just dropping out now but it's only a forum man. The people on here are helping people like me who are new to programming so just try not to get hung up on stuff like this.

webdev1958
03-04-2012, 11:31 AM
Well i'm just dropping out now but it's only a forum man. The people on here are helping people like me who are new to programming so just try not to get hung up on stuff like this.

No problem. Had he just apologised when I first caught him out, it would have been the end of the matter. But he has gone on to do it on far too many occasions for me to think it's not a deliberate action on his part and hence I eventually went down the legal route and as I said before, it's now out my hands but I will continue to highlight false statements about me wherever I think it is appropriate to do so :)

Philip M
03-04-2012, 11:33 AM
MancunianMacca - You are coming to the party a little late in the day. wevdev1958 is the screen name of a person who has been banned from this forum (under different names) on several occasions. He pours out angry bile, uses the word "liar" and "lies" with gay abandon, and threatens all and sundry with legal action.

The truth is that this man is a troll and insane. That is defamatory. Feel free to sue me if you wish. My defence is simple - the defamatory words are true.

webdev1958
03-04-2012, 11:41 AM
.......and threatens all and sundry with legal action. ......

hmmmm, didn't sound like a threat to me. It was meant to be a statement of what I have done :)

webdev1958
03-04-2012, 01:41 PM
The version that works without JavaScript is always much easier to build.......

Are you speaking on behalf of yourself only, or attempting to speak on behalf of everyone else as well? ;)

Depending on their level of skill, there are people who will argue that it isn't as it depends on the client's website spec's.

webdev1958
03-04-2012, 02:29 PM
wevdev1958 is the screen name of a person who has been banned from this forum (under different names) on several occasions.......

Well, that's news to me. I have been here for 11 months now and made over 220 posts and have never received any notification from anyone about being banned from anywhere - and you are coming up with the above accusations just now :confused: and without any supporting evidence?

I don't get into discussions about who people really are in forums because even someone with an IQ equal to their shoe size should be able to see that anyone can pretend to be anyone they like in forums if they wanted to. For instance, about 3 weeks ago now, I was talking to a Phillip M about their drug and child abuse issues. I don't suspect it was you I was talking to, but it may very well have been for all I know. I don't know for sure or care one way or the other.

Surely it is extremely obvious that anyone can register as Philip M, webdev1958 or any other username they see somewhere on any website where the username is not already registered and then proceed to say what they like or pretend to be whoever they like.

Philip M
03-04-2012, 03:59 PM
Well, that's news to me. I have been here for 11 months now and made over 220 posts and have never received any notification from anyone about being banned from anywhere - and you are coming up with the above accusations just now :confused: and without any supporting evidence?

I don't get into discussions about who people really are in forums because even someone with an IQ equal to their shoe size should be able to see that anyone can pretend to be anyone they like in forums if they wanted to. For instance, about 3 weeks ago now, I was talking to a Phillip M about their drug and child abuse issues. I don't suspect it was you I was talking to, but it may very well have been for all I know. I don't know for sure or care one way or the other.

Surely it is extremely obvious that anyone can register as Philip M, webdev1958 or any other username they see somewhere on any website where the username is not already registered and then proceed to say what they like or pretend to be whoever they like.

I think, bullant, we can safely employ your favourite word - liar!

Taro
03-04-2012, 04:40 PM
Hello,

If I'm not mistaken, I think that websites that go with this case are fine. I don't believe there are laws that relate to handicap features and required JavaScript codes. For example, small business sites are from the private sector, it is up to non-private sector sites/ organizations etc. to provide features that allow handicapped persons to view a site easier.

Besides, that was not the main purpose of why JavaScript was created anyways. One reason was to add greater functionality to the pages. There should should be any controversy over disablement of scripting, as to simply not go to the site, and/ or find an alternative. Some people want people to get a better viewing experience, or the script itself actually has something to do with improving the security.

VIPStephan
03-04-2012, 04:54 PM
OK, enough said, I guess. Sorry, Taro, that your thread has been taken in this direction.
Folks, it took me a few seconds to type “sue accessible website” into my favorite search engine and getting these among the results:

http://arstechnica.com/tech-policy/news/2007/10/lawsuit-over-website-accessibility-for-the-blind-becomes-class-action.ars
http://webaxe.blogspot.com/2011/02/disney-other-recent-web-accessibility.html


Now, if I find any more posts that aren’t related to the subject and just accusing others of lying, being picky about how statements are phrased, or provoking negative reactions from others, those people will receive an infraction. Don’t make me close this thread!

MancunianMacca
03-04-2012, 04:58 PM
Hey Taro, sorry your thread was lost. I you could just create a page on your site called nojs.html with a message saying to view this website properly enable javascript.

In the head just use this code.


<html>
<head>
<noscript>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/nojs.html">
</noscript>
</head>
<body>
Please enable javascript
</body>
</html>


you will need to put the <noscript> part on evrypage of your website incase a peson follows a link like yourdomain.com/about.html

felgall
03-04-2012, 06:51 PM
Hey Taro, sorry your thread was lost. I you could just create a page on your site called nojs.html with a message saying to view this website properly enable javascript.

In the head just use this code.


<html>
<head>
<noscript>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/nojs.html">
</noscript>
</head>
<body>
Please enable javascript
</body>
</html>


you will need to put the <noscript> part on evrypage of your website incase a peson follows a link like yourdomain.com/about.html

Unfortunately <noscript> isn't valid in the head of the page. It is a block level tag that can only be used in the body.

To get it to validate you would need to remove the noscript tags and instead use JavaScript to remove that part of the page when JavaScript is enabled.

MancunianMacca
03-04-2012, 08:19 PM
Unfortunately <noscript> isn't valid in the head of the page. It is a block level tag that can only be used in the body.

To get it to validate you would need to remove the noscript tags and instead use JavaScript to remove that part of the page when JavaScript is enabled.

Well it works on y site take a look www.mancunianmacca.co.uk (disable javascript)

felgall
03-04-2012, 08:45 PM
Well it works on y site take a look www.mancunianmacca.co.uk (disable javascript)

I didn't say that it doesn't work in some browsers - I said it is invalid HTML - which means that browsers don't have to ensure that it works.

Another thing you have overlooked is that modern browsers provide an option for whether or not to allow meta redirects and so many of those with JavaScript disabled will also have meta redirects disabled.

The safer way to do it is to reverse it and use JavaScript to redirect those who have JavaScript enabled to the page where the javaScript is required leaving those with JavaScript disabled on the original page.

Philip M
03-04-2012, 08:48 PM
Well it works on y site take a look www.mancunianmacca.co.uk (disable javascript)

It is not valid HTML. As felgall says, to get it to validate you must place <noscript> tags in the body. Please do not try to teach your grandmother(s) to suck eggs. :)

MancunianMacca
03-04-2012, 08:51 PM
It is not valid HTML. As felgall says, to get it to validate you must place <noscript> tags in the body. Please do not try to teach your grandmother(s) to suck eggs. :)
I did not disagree if you would have looked. I stated that it works on my website.

MancunianMacca
03-04-2012, 08:53 PM
Lets stop bumping this thread now anyway, you were right, :D

felgall
03-04-2012, 09:11 PM
I did not disagree if you would have looked. I stated that it works on my website.

You mean that it works in the particular browser you tested in with the particular settings you have that browser configured to use. If you tested in enough different browsers you would eventually find one that applies the standard that therefore ignores the noscript tag because it is misplaced. If you test in any browser that is comnfigured to disable meta redirects it wouldn't work either.

The safest way to have two separate pages with one for when JavaScript is enabled and one for when it is not is to make the one where JavaScript isn't available the one everyone goes to first and use a lingle line of JavaScript in the head of the page to redirect to the JavaScript page. One of the very few situations where it is appropriate to put JavaScript in the head of the page rather than at the bottom of the body.

I believe that HTML 5 is redefining where a noscript tag is valid in order to allow it to be wrapped around styles in the head of a page (the only place where it actually makes sense to use a noscript tag but which is not permitted by the current standard effectively making noscript obsolete until an HTML 5 standard is released - if that is still a part of what HTML 5 allows by the time it does become a standard).

rnd me
03-04-2012, 11:39 PM
It is not valid HTML. As felgall says, to get it to validate you must place <noscript> tags in the body. Please do not try to teach your grandmother(s) to suck eggs. :)

check again, your'e thinking of html from the 90s. <noscript> is valid anywhere now. unless you still use xhtml or html4 (yikes) you can use noscript as you expect and validate.

i know this tread got hijacked, but i want to reiterate that the fastest, most accessible, most satisfying to use and fastest to develop sites/apps rely heavily on javascript.
now that JS is making a big move onto the server, it's getting easier to provide non-js versions because you can run the same client templates and dom operations on the server before printing.

I still think putting the client in the driver's seat provides the best UX, but there are decent seo and legacy reasons to provided a non-interactive informational view. You can use other methods (pings, sitemap, non-<A>-linked html views, etc) to populate search engine results, so a js-only site is not always invisible to google and bing. Again, you actually need JS to provide cutting-edge accessibility. Along with that accessibility is just plain usability. HTML5 helps a lot (type=date, progress, sliders, list=, required, pattern, placeholder, etc), but you still need JS to provide those features to sub-par browsers.

generally, when talking about any single-digit subset of clients, you need to weight the pros and cons of supporting that particular group be it disabled users, IE7, no-js, no-css, N4, etc.
The cost of supporting them might not be negligible. The needs of the many outweigh the needs of the few and compelling experience for most is better than a bland experience for all.
who cares if everyone can use a site if it's slow, hogs my data plan, and makes me do extra clicks?

Often certain small groups of users incur double-digit percentages of dev time. I've found that jettisoning the heavy cargo enables the main crew to sail far faster towards that horizon of a perfect site.



in terms of accessibility, the main concept for any site developer is provide keyboard access to the site. Both blind and physically impaired users use the keyboard to navigate. If you can set your mouse behind your screen and use your site in full, nobody will ever sue you. If you find that there's a section you can't get to, a date you can't choose, or that it's hard to tell what link you've got tabbed, you might want to investigate ways to make keyboard navigation more manageable (jumpto menus, ARIA landmark and rolls, tabindex, .hover, :hover{}, href="#x", :focus{outline:x}, etc).

webdev1958
03-04-2012, 11:57 PM
.....unless you still use xhtml or html4 (yikes) you can use noscript as you expect and validate.

What's wrong with html4? It's still the latest standard. html5 is still in development and will be for quite a few years yet. So why use a currently half baked html5 standard which may be different when it is finalised years down the track to what it is now. Consequently, browser support for it is currently patchy at best and it's amazing how many noobies come wandering into forums dragging their brand new shiny html5 code behind them wondering why it doesn't work in all browsers :eek:. Gee willackers.....:D...it's probably got something to do with the fact html5 is only half baked atm and has a long way to go before it is even close to finished and ready to be used with reliability on live commercial websites.

But this is another issue and has been discussed countless times elsewhere :)

rnd me
03-05-2012, 12:25 AM
html5 is still in development and will be for quite a few years yet. So why use a currently half baked html5 standard which may be different when it is finalised years down the track to what it is now. :)


i guess my best answer comes in the form of an example.
when i wrote this image editor (http://danml.com/pub/photo2.htm), it was for a class project in which we had to make any webpage. It was a neat web page, but it only worked in firefox beta 3 (gran paradiso).


my instructor had made the mistake of saying that photo-editing cannot be done in javascript...

there was no chrome at the time (2007), and no other browser really supported the html5 <canvas> tag in full. In short, i was coding to a promise; less than a draft, a single-browser maker's idea of a spec with their own fill-ins to boot.

years later, i discovered that it functioned on an i pad. it worked in chrome. IE got banned for life back then, but i could probably make it work in IE9/10 with minimal fuss. About a year or so ago, I did spend about 20 mins making a default layout for touch-screens that can't use drag and drop. That's the only touches to the code i'd made in years...


the lesson is much the same as from the early 20th century when cars were getting better, faster, and cheaper every year. Many folks said they were waiting for the price and performance to get to a certain level. When it did, they wanted to wait until it got even cheaper. Henry Ford pointed out that cars will always get cheaper and faster, it's a matter of how long you want to walk before you start driving.

jalarie
03-05-2012, 12:34 AM
This may be interesting: A Google search for "accessibility javascript discrimination lawsuit" turned up the Wiki link at http://en.wikipedia.org/wiki/Web_accessibility#Legally_required_web_accessibility which includes:



United Kingdom

In the UK, the Equality Act 2010 does not refer explicitly to website accessibility, but makes it illegal to discriminate against people with disabilities. The Act applies to anyone providing a service; public, private and voluntary sectors. The Code of Practice: Rights of Access - Goods, Facilities, Services and Premises document[8] published by the government's Equality and Human Rights Commission to accompany the Act does refer explicitly to websites as one of the "services to the public" which should be considered covered by the Act.


Notice that it even applies to the private and voluntary sectors.

VIPStephan
03-05-2012, 12:35 AM
The cost of supporting them might not be negligible.


Depending on the purpose of the site it actually might because you’re ideally building the non-JS version at first anyway and enhancing it with JS then. Of course, this doesn’t apply if we’re talking about the next photo editing web application but really, most websites don’t fall into this category, not even online banking services or web marketplaces (in theory such could be built without the need of JS and still with a totally acceptable user experience).



The needs of the many outweigh the needs of the few and compelling experience for most is better than a bland experience for all.


Well, besides the fact that a well designed site (let’s take a web marketplace as example) doesn’t have a “bland experience” in the first place, even without JS, it is quite an exaggeration to state that the bland experience would apply to everybody. As said, even if a non-JS version would result in a “bland” experience, it would certainly only affect those people with JS disabled. That doesn’t mean, however, that they should be completely ignored and get a completely unusable site, or that one should make their experience deliberately bland just to show them.

And personally, I don’t like the attitude that the needs of the many outweigh the needs of the few because most of the times today in our developed and civilized societies, there are almost no vital needs that could really justify ignoring and overruling a minority just because they are fewer in numbers. But that’s getting quite philosophical so I’m just leaving it like that without going into the details of my thesis.



What's wrong with html4? It's still the latest standard. html5 is still in development and will be for quite a few years yet. So why use a currently half baked html5 standard which may be different when it is finalised years down the track to what it is now.


I’ll have to agree with this.

webdev1958
03-05-2012, 12:37 AM
the lesson is much the same as from the early 20th century when cars were getting better, faster, and cheaper every year. Many folks said they were waiting for the price and performance to get to a certain level. When it did, they wanted to wait until it got even cheaper. Henry Ford pointed out that cars will always get cheaper and faster, it's a matter of how long you want to walk before you start driving.

yes I suppose that's one way of looking at it but imo there is still too much inconsistency between the major browsers for html5 support and way too much uncertainty on how much different html5 will be years down the track when it is officially recommended by the w3c to what it is today.

I suspect a lot of pages built with html5 today will break in a few years when html5 is eventually finalised.

Do you recall the history behind the need for quirksmode as a result of web authors jumping the gun in the past? History will most likely repeat itself when html5 is eventually recommended by the w3c.

The point I am in effect making is that unless you really, really, really need to use draft html5 specific elements right now, you are more likely to still have a robust web page when html5 is released if you use the the Strict doctype for either xhtml or html4. Both will still happily render away successfully in browsers when html5 is finally recommended by the w3c in years down the track.

felgall
03-05-2012, 02:10 AM
Do you recall the history behind the need for quirksmode as a result of web authors jumping the gun in the past? History will most likely repeat itself when html5 is eventually recommended by the w3c.

Very true. The entire reason for quirks mode was too many people implementing pages that relied on the draft version of CSS 2 that was implemented in IE5 - which came out just before the draft was changed to completely change how the box model worked.

There are currently lots of things in the HTML 5 draft that are contradictory or unnecessary that will obviously need to be cleaned up before HTML 5 becomes a standard. For example consider the following HTML 5 tag:


<input name="html5" type="text" required pattern="^$">

The required attribute requires that the field contain some content while the pattern attribute requires that the field be empty - and so that input field must always fail validation. Obviously the required attribute needs to be deleted from the draft as it is unnecessary since pattern="^.+$" means exactly the same thing (except for not being able tospecify that a field must contain zero and at least one character at the same time).

jalarie
03-05-2012, 03:28 AM
Just consider how much supposed JavaScript you see that contains any of the following long dead code: alert, prompt

What newer code do you use to tell the user of unusual situations and get back a response on how to handle them?

webdev1958
03-05-2012, 03:38 AM
What newer code do you use to tell the user of unusual situations and get back a response on how to handle them?

There is nothing actually wrong with using alert() or prompt(). The only thing I don't like about them is that they look "ugly".

There are many alternatives you can use like Lightbox effects or you can customise your own "popup" alert and prompt boxes using just plain html and css and some basic javascript to process any user inputs.

If you customise your own alert and prompt popups you can make them look and function however you like. And you don't need any html5/css3 features at all.

Logic Ali
03-05-2012, 04:50 AM
You are not even remotely qualified to give me legal advice as you have attempted in the past and your "legal advice" is at best total garbage and at worst blatant cowardly lies in my particular circumstances.
I would expect your legal adviser to advise you that it is inadvisable to take legal advice from anyone in a different jurisdiction to your own.

Logic Ali
03-05-2012, 05:04 AM
OK, it might be very low in percentage, and hits are not equal to unique visitors (one visitor can make several hits, or several hits can come from one visitor only, respectively) but shows that itís certainly possible that people browse without JS. I donít see any reason to exclude them, especially when itís not a lot of additional effort to provide proper accessibility.
As far as I'm concerned the only remotely safe way to surf the web is with JS disabled by default, only enabling it selectively as required with the ability to exclude third-party code and iframe generation.
In so doing I encounter a shamefully high proportion of sites that render nothing or practically nothing without JS, a situation compounded by the total absence of any warning as to why nothing is appearing.
That state of affairs in itself must constitute a widespread accessibility issue.

webdev1958
03-05-2012, 06:37 AM
I would expect your legal adviser to advise you that it is inadvisable to take legal advice from anyone in a different jurisdiction to your own.

Yep that is totally correct and common sense also tells me to treat as garbage any "legal advice" from people not at all qualified to give it to me and to consider legal advice only from those who have the qualifications I require them to have. :cool:

There are too many wannabe lawyers in forums who have no idea what they are talking about in regard to my particular circumstances and many of them don't like being reminded of that fact. :)

felgall
03-05-2012, 06:40 AM
There is nothing actually wrong with using alert() or prompt(). The only thing I don't like about them is that they look "ugly".
.

In Opera they all have a "Disable JavaScript for this page" checkbox.

In IE9 the second one to pop up has a "disable further dialogs" link.

So you can't expect more than one to ever pop up. They are intended for debugging purposes only (for those who don't know how to use the built in debugger) which is why browsers are starting to include options in the dialog itself to disable further dialogs (just in case you get stuck in a loop). I have images of both the Opera and IE alert boxes showing the extra option at http://javascriptexample.net/badjs12.php - the confirm and prompt dialogs have the same extra options in those browsers allowing your visitor to disable part or all of your script.

There's nothing wrong with using the dialogs for debugging a script but they should be removed before it goes live to prevent your visitors from changing the functioning of your page.

The correct way to do dialogs in modern browsers is to build your own using a lightbox script - that way your visitor's can't turn them off with the extra option you didn't want to be there.

webdev1958
03-05-2012, 06:47 AM
Like I went on to say after that -



There are many alternatives you can use like Lightbox effects or you can customise your own "popup" alert and prompt boxes using just plain html and css and some basic javascript to process any user inputs.

If you customise your own alert and prompt popups you can make them look and function however you like. And you don't need any html5/css3 features at all.

felgall
03-05-2012, 06:56 AM
Like I went on to say after that -

I was agreeing with that part of what you said.

I was pointing out the reason why alert, confirm, antd prompt should never be used in live script - the extra options they offer that you don't really want your visitors to be able to access. It isn't just a matter of them looking ugly (since some browsers now make them look like you used a lightbox script so they don't necessarily look ugly).

After all what's the point in using alerts to display the error message if the biggest link that displays on the second one for all your visitors using IE9 ensures that no more alerts will display on that page regardless of the continuing errors that your script detects. With a lightbox the error messages will continue to display.

Another alternative with form validation is to simply put the JavaScript error messages in the same spot in the page that the server side validation will put them.

webdev1958
03-05-2012, 07:05 AM
I'm not going to tell anyone they must not use alert boxes for purposes other than debugging because the bottom line is that depending on functionality it is a personal choice whether to use the default or customised alert boxes.

I still use alerts in some circumstances, although not very often, and will continue to use them where it is a valid option for me.

felgall
03-05-2012, 07:20 AM
I'm not going to tell anyone they must not use alert boxes for purposes other than debugging because the bottom line is that depending on functionality it is a personal choice whether to use the default or customised alert boxes.

The debugging options in alert etc in Opera and IE9 can't be turned off.

If you display an alert in Opera it contains the option to turn off JavaScript completely for the current page. If you display a second alert in IE9 it contains the option to turn off all future alerts for that page. The same applies to confirm and prompt.

Why would you want to display a message that asks your visitors to turn off your script?

webdev1958
03-05-2012, 07:30 AM
Why would you want to display a message that asks your visitors to turn off your script?

Are you asking me in particular or everyone?

If you're asking me in particular then I'n not going to waste time answering questions from you when you have on each occasion in the past when I have asked you to post evidence to support the "legal advicŽ" you posted, you have run away.

If you want me to take you seriously then show some courage for a change and answer my questions I first asked you and then I will return the courtesy and answer your questions. If you're not prepared to answer my questions then stop wasting my time by asking me questions :)

You can't have it both ways by expecting me to answer your questions when you first run away from answering mine.

felgall
03-05-2012, 08:36 AM
Are you asking me in particular or everyone?

Everyone.

Using an alert, confirm or prompt asks some of your visitors if they want to turn off JavaScript for your web page. It asks some other visitors if they want to cease displaying alerts/confirms/prompts on your page.

Since it only asks some people one question, other people a different question, and still others no question at all, it would only make sense to use any of them where you control the browser being used - either on an intranet or for debugging.

To return to what the OP was asking about with pages that only work with JavaScript enabled you would definitely need to avoid using alert, confirm, or prompt on a page that only works with JavaScript enabled. If you did use one of them then you are asking for your visitors to break your page by telling them to turn off the script.

It wasn't me that decided that alert confirm and prompt should only be used for debugging. It was the people who wrote Opera and Internet Explorer who changed the options that those dialogs display.

An alert now effectively asks the question of whether to continue running the script or not - click OK to continue or the other option to disable JavaScript for this page only. A confirm has three possible answers - OK to return true to the script, cancel to return false to the script or the third option that doesn't return to the script at all.

If you don't want to ask your visitors if they want to turn off JavaScript then you can't use alert, confirm or prompt because they will ask some of your visitors that question. If you dot want to ask that question you can't use them either because it will only ask some of your visitors that question, not all of them.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum