Alternative image output if user have Flash turned off


/ Published in: JavaScript
Save to your folder(s)

Also we can use HTTP_ACCEPT


Copy this code and paste it in your HTML
  1. <script language="javascript">
  2. var plugin;
  3. var version = 5;
  4. var flash = false;
  5. if (navigator.plugins)
  6. {
  7. if (navigator.plugins["Shockwave Flash"])
  8. {
  9. plugin = navigator.plugins["Shockwave Flash"].description;
  10. flash = parseInt(plugin.charAt(plugin.indexOf('.') - 1)) >= version;
  11. } else {
  12. if ((navigator.userAgent.indexOf('MSIE') != -1)
  13. && (navigator.userAgent.indexOf('Win') != -1))
  14. {
  15. var vb = '<script language="vbscript">\n'
  16. + ' on error resume next\n'
  17. + ' flash = IsObject(CreateObject(\n'
  18. + ' "ShockwaveFlash.ShockwaveFlash.' + version + '"))\n'
  19. + '<' + '/script>';
  20. document.write(vb);
  21. }
  22. }
  23. }
  24. if ( flash ) {
  25. // write flash code
  26. document.write('<object>...</object>');
  27. } else {
  28. // alternative image code
  29. document.write('<img src=""/>');
  30. }
  31. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.