473,416 Members | 1,559 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Detecting Javascript availability...

We have this web-app that requires Javascript to
be enabled in the UA (this is okay'ed by our customer).

Now I want to make a "pre" page before the login screen,
informing the user that he/she must have JS turned on.

Problem is that I would prefer to show this page only if
JS isn't on. (and hence, I have a "Chicken/Egg" problem).

If neccessary, we can require IE-only as UA.

Any pointers, suggestions or comments on thisone?

TIA...

--
Dag.
Jul 23 '05 #1
11 1759
> "Dag Sunde" <me@dagsunde.com> wrote:
news:7L******************@juliett.dax.net....

We have this web-app that requires Javascript to
be enabled in the UA (this is okay'ed by our customer).

Now I want to make a "pre" page before the login screen,
informing the user that he/she must have JS turned on.

Problem is that I would prefer to show this page only if
JS isn't on. (and hence, I have a "Chicken/Egg" problem).

If neccessary, we can require IE-only as UA.

Any pointers, suggestions or comments on thisone?

TIA...


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Check JavaScript
</title>
</head>
<body>
<script type="text/javascript">
function proceed(){
document.location.href = 'http://www.download.com'
}
onload = proceed
</script>
<noscript>
<h1 style="color:red;text-align:center;">
JavaScript must be enabled
</h1>
<p>
perhaps some direction on how to enable javascript
</p>
</noscript>
</body>
--
BootNic Tuesday, June 21, 2005 8:50 AM

Humor is just another defense against the universe.
*Mel Brooks*

Jul 23 '05 #2
"BootNic" <Bo*****@bounce.prodigy.net> wrote in message
news:K2****************@newssvr33.news.prodigy.com ...
"Dag Sunde" <me@dagsunde.com> wrote:
news:7L******************@juliett.dax.net....

We have this web-app that requires Javascript to
be enabled in the UA (this is okay'ed by our customer).

Now I want to make a "pre" page before the login screen,
informing the user that he/she must have JS turned on.
<snipped/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Check JavaScript
</title>
</head>
<body>
<script type="text/javascript">
function proceed(){
document.location.href = 'http://www.download.com'
}
onload = proceed
</script>
<noscript>
<h1 style="color:red;text-align:center;">
JavaScript must be enabled
</h1>
<p>
perhaps some direction on how to enable javascript
</p>
</noscript>
</body>


Thanks a lot!

I now realize that the <noscript> tag is supported all the way
to xhtml strict, and all is well.

--
Dag.
Jul 23 '05 #3
Dag Sunde wrote:
"BootNic" <Bo*****@bounce.prodigy.net> wrote in message
news:K2****************@newssvr33.news.prodigy.com ...
"Dag Sunde" <me@dagsunde.com> wrote:
news:7L******************@juliett.dax.net....

We have this web-app that requires Javascript to
be enabled in the UA (this is okay'ed by our customer).

Now I want to make a "pre" page before the login screen,
informing the user that he/she must have JS turned on.


<snipped/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Check JavaScript
</title>
</head>
<body>
<script type="text/javascript">
function proceed(){
document.location.href = 'http://www.download.com'
}
onload = proceed
</script>
<noscript>
<h1 style="color:red;text-align:center;">
JavaScript must be enabled
</h1>
<p>
perhaps some direction on how to enable javascript
</p>
</noscript>
</body>

Thanks a lot!

I now realize that the <noscript> tag is supported all the way
to xhtml strict, and all is well.


Not as well as you think, and its material to your question.

Leave the noscript section in the page itself. If script is not
available (whether not in the UA or disabled) then the page won't be
redirected and the user will see it. Then, it doesn't matter whether
noscript is supported or not.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #4
"Dag Sunde" <me@dagsunde.com> wrote in message
news:7L******************@juliett.dax.net...
We have this web-app that requires Javascript to
be enabled in the UA (this is okay'ed by our customer).

Now I want to make a "pre" page before the login screen,
informing the user that he/she must have JS turned on.

Problem is that I would prefer to show this page only if
JS isn't on. (and hence, I have a "Chicken/Egg" problem).


Place the login section in a hidden <div> and then make another unhidden
<div> which has some suitable message about javascript.

Once the page loads, hide the message and unhide the login section.
Jul 23 '05 #5
VK
Using the Occam's raisor (also called KISS in California) :

(It works for all browsers starting with Netscape 2.0 and including
Lynx)

<html>
<head>
<title>Welcome to my company!</title>
<noscript>
<meta http-equiv="Refresh"
content="1;URL=http://www.myserver.com/noscript.html">
</noscript>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<p>Login page</p>
</body>
</html>

Jul 23 '05 #6
"Randy Webb" <Hi************@aol.com> wrote in message
news:8_********************@comcast.com...
Dag Sunde wrote:

<snipped/>
I now realize that the <noscript> tag is supported all the way
to xhtml strict, and all is well.


Not as well as you think, and its material to your question.

Leave the noscript section in the page itself. If script is not
available (whether not in the UA or disabled) then the page won't be
redirected and the user will see it. Then, it doesn't matter whether
noscript is supported or not.


I did it like below, can you see any problems with that?

<?xml version='1.0' encoding='iso-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>RegWeb - Sjekker JavaScript</title>
<link type="text/css" rel="stylesheet" href="styles/ekstranett.css" />
<script type="text/javascript">
function fwdOnScriptPresent() {
document.location.href = './pages/UASettings.asp';
}
</script>
</head>

<body onload="fwdOnScriptPresent();">
<noscript>
<h2 style="color:red;">
JavaScript must be supported, or turned on...
</h2>
<h3>How to proceed:</h3>
<p>yada, yada...</p>
</noscript>
</body>
</html>

--
Dag.
Jul 23 '05 #7
Dag Sunde wrote:
"Randy Webb" <Hi************@aol.com> wrote in message
news:8_********************@comcast.com...
Dag Sunde wrote:
<snipped/>
I now realize that the <noscript> tag is supported all the way
to xhtml strict, and all is well.


Not as well as you think, and its material to your question.

Leave the noscript section in the page itself. If script is not
available (whether not in the UA or disabled) then the page won't be
redirected and the user will see it. Then, it doesn't matter whether
noscript is supported or not.

I did it like below, can you see any problems with that?

<?xml version='1.0' encoding='iso-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>RegWeb - Sjekker JavaScript</title>
<link type="text/css" rel="stylesheet" href="styles/ekstranett.css" />
<script type="text/javascript">
function fwdOnScriptPresent() {
document.location.href = './pages/UASettings.asp';
}
</script>
</head>

<body onload="fwdOnScriptPresent();">
<noscript>


Remove the noscript tag.
<h2 style="color:red;">
JavaScript must be supported, or turned on...
</h2>
<h3>How to proceed:</h3>
<p>yada, yada...</p>
</noscript>
Remove the closing noscript tag.
</body>
</html>


Consider this scenario:

The UA doesn't support redirection via script. Whether it doesn't
support .href or the location object. The script will fail, yet the user
won't see the noscript section. Leaving it out leaves it readable by
anyone, for whatever reason, that doesn't get redirected.

There is an ongoing thread at the moment entitled "Problems with JS
turned off" that discusses this very point.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #8
VK wrote:
Using the Occam's raisor (also called KISS in California) :

(It works for all browsers starting with Netscape 2.0 and including
Lynx)
Are you positive about that? I'm not.
<html>
<head>
<title>Welcome to my company!</title>
<noscript>
<meta http-equiv="Refresh"
content="1;URL=http://www.myserver.com/noscript.html">


IE6 explicitly allows the disabling of META Refresh. If the browser is
Meta disabled and script disabled your user will be staring at a blank
screen (test it).

Also, the noscript element is not allowed in the head section anyway.
And what a browser does with invalid HTML is a guess at best.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #9
Dag Sunde wrote:
"Randy Webb" <Hi************@aol.com> wrote [...]:
Dag Sunde wrote: <snipped/>
> I now realize that the <noscript> tag is supported all the way
> to xhtml strict, and all is well.


Not as well as you think, and its material to your question.

Leave the noscript section in the page itself. If script is not
available (whether not in the UA or disabled) then the page won't be
redirected and the user will see it. Then, it doesn't matter whether
noscript is supported or not.


I did it like below, can you see any problems with that?


Alas, I can see plenty of them.
<?xml version='1.0' encoding='iso-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Whatever M$ tells you, Internet Explorer (IE) does not support XHTML. I
do hope that you don't serve this XHTML as text/html to workaround that,
but as application/xhtml+xml and serve an HTML alternative as text/html
to IE and other non-XHTML UAs.

<http://www.hixie.ch/advocacy/xhtml>

Although it is Valid markup, there is no point whatsoever in declaring XHTML
1.0 Transitional. Like the man said, you can't eat the cake and have it.
Either you want clean markup (e.g. to speed up the parsing process) or you
don't want it. If the former, declare HTML 4.01 Strict, XHTML 1.0 Strict
or even XHTML 1.1 Strict if you have to; if the latter, declare HTML 4.01
Transitional.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
The character declaration meta element is redundant in valid XHTML served
with the appropriate Content Type. An XML parser has to determine the
encoding of a document before building the parse tree; a character
declaration of this kind simply is too late at this line.
[...]
<link type="text/css" rel="stylesheet" href="styles/ekstranett.css" />
This alone is not supposed to work in correctly served XHTML. XHTML
documents are the result of an application of XML and so an XML processing
instruction (PI) before the root element (here: HTML) is required to
specify the used stylesheet. This means you either specify the CSS
resource in the PI, or provide a `style' element with an `id' attribute
value while referring to the fragment identifier in the PI. The former
is recommended to avoid declaring style content as CDATA or to escape
markup characters (e.g. `>', both CSS child selector and XML TAGC
delimiter).

<http://www.w3.org/TR/xhtml1/guidelines.html#C_14>
<script type="text/javascript">
function fwdOnScriptPresent() {
document.location.href = './pages/UASettings.asp';
}
[...]
<body onload="fwdOnScriptPresent();">
The function is redundant so far (and therefore a little bit inefficient
compared to the alternative): the one line could have been easily included
in the event handler attribute value.

`document.location' is deprecated long since. Use `window.location' or
`location' if you can be sure that in the targeted UAs the `window' property
would refer to the Global Object (you can save one lookup this way and your
code becomes shorter).

No syntax errors here, but you should be aware that if you include e.g.
certain comparison operators to the script without either declaring script
content as CDATA (character data) or escaping those operators you will run
into trouble; the default content type of the `script' element is PCDATA
(parsed CDATA): e.g. an undeclared `<' is considered an STAGO delimiter.
That's why it is recommended to include script files (containing unescaped
code without CDATA declarations, of course) instead.

<http://www.w3.org/TR/xhtml1/diffs.html#h-4.8>
<noscript>
There is no point in using the `noscript' element in this document, unless
the above code is just an example and you want a timed redirection. If not,
just let the script code execute within the `head' element and a JS capable
UA will never reach this line.
<h2 style="color:red;">
<http://www.w3.org/QA/Tips/color>
JavaScript must be supported, or turned on...
The assumption "as is" is wrong and based on a misconception. Although
non-compliant regarding the HTML 4.01 Specification, many user agents tend
to ignore the value of the `type' attribute of the `script' element and
use the default scripting language always. If, for some strange reason,
the default scripting language of a UA would be not JS, JS could be
supported and this section be displayed anyway. I have yet to see such
an UA, though.
</h2>
<h3>How to proceed:</h3>
<http://www.w3.org/QA/Tips/headings>
[...]
</noscript>
[...]

HTH

PointedEars
--
Multiple exclamation marks are a sure sign of a diseased mind.
-- Terry Pratchett
Jul 23 '05 #10
VK wrote:
Using the Occam's raisor (also called KISS in California) :
I'm afraid it's more stupid than simple.
(It works for all browsers starting with Netscape 2.0 and including
Lynx)

[gibberish code]


Certainly not. It is far from being Valid HTML, let alone a usable
document.
PointedEars
Jul 23 '05 #11
"Thomas 'PointedEars' Lahn" <Po*********@web.de> wrote in message
news:12****************@PointedEars.de...
Dag Sunde wrote:
"Randy Webb" <Hi************@aol.com> wrote [...]:


<snipped />

Thank you for a long list of explanations to the different issues,
both of you...

some of it was sloppyness in my example, some of it was completely new
to me, and some it is hard to believe.

I'll try to absorb it during the next week (I'm on vacation :-)).

Tank you.

--
Dag.
Jul 23 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Frank | last post by:
Hello, I'm a total newbie on Javascript, and with a lot of help and some copy and paste managed to get things running. On my site: http://home.wanadoo.nl/homepage I use a form from Bravenet....
25
by: Ryan Stewart | last post by:
I'm working on a project to collect web application usage statistics. What are the recommended ways of detecting whether a browser is JavaScript enabled and/or capable? Obviously I can write a...
4
by: Jeremy | last post by:
How can I prove uptime (or quantify downtime) on an ASP.NET 1.1 Web application (running on an IIS6 Windows Server Standard server)? What's going on here is that I'm considering the feasability...
2
by: Russ | last post by:
Are there any code samples out there which detect the presence of a web service..ie windows app on a laptop which is able to talk to web services. If the laptop is offline, detect that the service...
3
by: regtrashcan | last post by:
I have a webpage that detects whether Shockwave Player is installed and the version number. The javascript/vbscript that I use has worked fine until the latest release of the Shockwave Player. I am...
79
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the...
13
by: mofmans2ndcoming | last post by:
Hi all, I have looked through MSDN on this one and can't seem to find the answer anywhere. I have created a JavaScript that will launch a meeting request for an address selected from a list....
5
by: Greg Smith | last post by:
I have a series of applications that assume other applications are installed. Is there a way to detect the installation of a specific application? Any help is greatly appreciated.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.