Detect: JavaScript Enabled or Disabled
Status: New User - Welcome
Joined: 02 Aug 2005
Posts: 1
Reply Quote
I am looking for a way to test if the user has disabled javascript on their browser. I am building a JS/CSS menu which I would like to provide an backup for should they have JS turned off.
Back to top
Status: Interested
Joined: 04 Oct 2003
Posts: 16
Reply Quote
Just use <noscript>.....</noscript> to have the content you want if javascript is turned off. There's some validation issues with <noscript>, it can't be in a containing block level div, p or a few others.

Or you can have the default behavior overridden by javascript, that's I think the best choice, for example have a CSS library file for the active JS triggered component triggered by something like this:

:: Code ::
<title>test page</title>
<link rel="stylesheet" href="/css/default.css" type="text/css">
<script type="text/javascript">document.write('<link rel="stylesheet" href="/css/menu-js.css" type="text/css">');</script>
// you have to escape the document.write <link... html a bit to avoid it being parsed by the browser.

It's hard to say more without seeing a code sample of what you're doing.

Oh, and welcome to the forums.
Back to top
you can check that javascript is enabled or not
Status: New User - Welcome
Joined: 21 Nov 2007
Posts: 1
Reply Quote
A script can be detected by using <noscript></noscript> tag
If a message placed in noscript tag displayed this mean javascript is no enabled

<script type="text/javascript">
document.write("Hello World!")
<noscript>Your browser does not support JavaScript!</noscript>
if enabled
print helloworld
Your browser does not support JavaScript![/code]
Back to top
Display posts from previous:   

All times are GMT - 8 Hours