Manoj Singh
Manoj Singh

Reputation: 7707

How to check flash and javascript installed/enable/disable on browser using JQuery

I am using JQuery.

I have got one link as given below:

<li><a href="http://staging/english/Skywards/skywards.aspx" id="skywardsTopLoginLink">Login</a></li>

Now I want to check on page load whether Flash/javascript is installed or disabled and according to output the Login link will work, I mean if flash/javascript is disabled or not installed then it will go to the above Href else it will open jQuery model dialog box for login functionality

Upvotes: 2

Views: 5436

Answers (2)

Nishant
Nishant

Reputation: 55866

try to set a cookie onLoad, and read it on server-side. If JS disabled there will be no cookie. Use <noscript> tag to inform user to enable it.


User SWFObject to detect Flash. As mentioned here: Cross Browser Flash Detection in Javascript

Now, there are two things.

If you just want to show alternate content/link use <noscript>as mentioned here http://www.w3schools.com/tags/tag_noscript.asp

If you want your webapplication to serve content that does not uses JS facilities, you may want to drop a cookie. Like here: http://www.w3schools.com/JS/js_cookies.asp try to read this cookie in server side code and set this info (in session) whether or not the user has JS enabled browser. Then use this info to serve non-JS content for future pages/requests.


realized you have JQuery, you can very well use this plugin http://plugins.jquery.com/project/Cookie

Upvotes: 0

Shikiryu
Shikiryu

Reputation: 10219

To load and check flash version etc, use and load SWFObject like this (it's just an example, check their documentation for more details) :

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myId", "9.0.115", "expressInstall.swf");
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
</script>

<div id="myContent">
  <p>Alternative content</p>
</div>

And add a <noscript> tag in case JS isn't activated.

Example about using this tag here.

That'll make your code like this :

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myId", "9.0.115", "expressInstall.swf");
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
</script>

<div id="myContent">
  <p>Alternative content for flash</p>
  <noscript>Alternative content for JS</noscript>
</div>

Be aware that people w/o JS will see both messages.

Upvotes: 1

Related Questions