javascript detection
Samo
Status: New User - Welcome
Joined: 19 Mar 2006
Posts: 3
Reply Quote
would someone be able to give the code snippet that detects if javascript is enabled or disabled?
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
:: Code ::
<noscript>Javascript is disabled</noscript>


Or of course any other content you want to put in the noscript tag. If that's not your question you'll have to use more words to describe what you want to know.
Back to top
Samo
Status: New User - Welcome
Joined: 19 Mar 2006
Posts: 3
Reply Quote
no, that's what i wanted, but, um, how would i be able to base an if/else statement off that?
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
Not a bad question as they go:

:: Code ::
<!-- if javascript is enabled -->
<script type="text/javascript>some_function();</script>
<!-- else if not enabled -->
<noscript>straight html for what you want to show</noscript>


I just included the html comments to show that this is actually an if type statement, only minus the literal 'if... else' words.

There is another way to use php to detect javascript, but it requires reloading the page, which in general is a pretty bad idea for standard pages.

Obviously you can't have any real if/then type syntax in the html itself, that would only work with some scripting language, and in the case of javascript, the thing has to work if javascript is turned off, and this is how you handle that case.
Back to top
Samo
Status: New User - Welcome
Joined: 19 Mar 2006
Posts: 3
Reply Quote
ok, thx, i'll let you know if i need any more help
Back to top
Display posts from previous:   

All times are GMT - 8 Hours