/    Sign up×
Community /Pin to ProfileBookmark

How can I determine if Javascript is enabled?

Is there a technique I can use to determine if JavaScript is enabled? If enabled, I’d use one set of menus, if disabled, I’d use another.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@pj59Jan 02.2005 — Hello!

Just put both sets of menus into your file. The one for users without js should be visible by default, the other one hidden (using css). Then put in a script which toggles the menu sets' visibility: the js menu will be made visible by js, the other one hidden. Due to the fact that the toggling will only work if js is enabled, you'd have the desired effect.

Regards PJ
Copy linkTweet thisAlerts:
@CharlesJan 02.2005 — And then what happens for those who have browsers that support neither JavaScript nor CSS?

The JavaScript dependent menu, draw all of it with document.write statemenst. The JavaScript free menu, put it inside a NOSCRIPT element. Then all will be well.
Copy linkTweet thisAlerts:
@age13kidJan 03.2005 — if you want to know what a "noscript" tag looks like on a webpage try this code
<i>
</i>&lt;html&gt;
&lt;head&gt;

<i> </i>&lt;title&gt;Untitled&lt;/title&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;form&gt;
&lt;!--this javascript ensures that anybody that doesnt use javascript wont see the menu--&gt;
&lt;script type="text/javascript"&gt;
&lt;!--hide script from older browsers
document.write('&lt;select name="whatever"&gt;&lt;option&gt;1&lt;/option&gt;&lt;option&gt;2&lt;/option&gt;&lt;/select&gt;');
--&gt;
&lt;/script&gt;
&lt;noscript&gt;
&lt;!--this is shown only if you have disabled javascript--&gt;
you disabled javascript or have a browser that does not support javascript... please enable javascript.
&lt;select name="nojs"&gt;
&lt;option&gt;3&lt;/option&gt;
&lt;option&gt;4&lt;/option&gt;
&lt;/select&gt;
&lt;/noscript&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

of corse you might want to change it around a little bit but this is the best way for me to show stuff only for non javascripters and seperatly for javascript enabled browsers
Copy linkTweet thisAlerts:
@CharlesJan 03.2005 — Do not use the NOSCRIPT element to ask people to enable JavaScript. We know JavaScript isn't enabled or supported and some have disabilities that prohibit the use of JavaScript. Those messages only offend.
×

Success!

Help @IcyBlueEyes spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...