StRichard Posted May 22, 2013 Share Posted May 22, 2013 (edited) Hi everyone! I've googled this problem for a week now, but I can't seem to find any suitable answers.I'm trying to get the javascript to output the two different div's by navigator.userAgent.match.All this because Steve Jobs didn't like flash...Since I don't own an IPad or IPhone, I thought that getting it to work on Firefox or IE wouldbe a good place to start.It should be said that my 2 year old daughter, probably is better at this scripting then me.I've obviously got no clue of what I'm doing here... In Firefox I only get the second div(display:block) to output. With flash off, I getthe standard "To enjoy this site you'll need..." and not the "img src=" of the first div.IE doesn't give me anything. Is there any chance that one of you experts could take a glance at this and explain to me what I'm doing wrong here? Any reply at all is highly appreciated ***************************************************<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML> <HEAD><meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <TITLE>Ål Kulturskule</TITLE> </HEAD><BODY> <div id="manglerflash" style="display:none"><center><param name="allowScriptAccess" value="always" /><img src="manglerflash.jpg" alt="manglerflash"><br><a href="https://itunes.apple.com/no/app/puffin-web-browser-free/id472937654?mt=8&uo=4" target="itunes_store">Puffin Web Browser - Denne linken tar deg direkte til AppStore.</a></center></div> <div id="aalkulturskule" style="display:block"><center><param name="allowScriptAccess" value="always" /><object type="text/html" data="http://aalkulturskule.wix.com/aalkulturskule?url=<?php echo urlencode(get_permalink($post->ID)); ?>&chs=200x100&force=true" style="height:1058px;width:980px;border:0;overflow:hidden"></object></center></div> <script language="javascript" type="content-type">if ((navigator.userAgent.match(/iPad/i) != null) || (navigator.userAgent.match(/iPhone/i) != null) || (navigator.userAgent.match(/iPod/i) != null) || (navigator.userAgent.match(/Firefox/i) != null) || (navigator.userAgent.match(/MSIE/i) != null)) { document.getElementById("manglerflash").style.display = "block"; document.getElementById("aalkulturskule").style.display = "none"; } </script> </body></html>********************************************************* Edited May 22, 2013 by StRichard Link to comment Share on other sites More sharing options...
Ingolme Posted May 22, 2013 Share Posted May 22, 2013 If you want to display an element to users who don't have Flash enabled, put it inside the <object> tag. No Javascript required. Your code doesn't look like it would work in any browser, actually. You should validate your HTML: http://validator.w3.org/You have <param> tags outside of <object> elements which isn't valid and won't actually do anything. The proper way to embed a Flash document is the following: <object type="application/x-shockwave-flash" data="file.swf" width="500" height ="440"> <!-- Param necessary for Internet Explorer --> <param name="movie" value="file.swf"> <!-- From here on browsers that don't have Flash will display the following code --> <p>Your browser does not support Flash.</p> </object> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now