javascript - Displaying relevant content -


i want display correct script , hide false script of code depending on device end user using.

    <ul class="pageitem"> <li class="button iphone"><input name="submit" value="app downloads" onclick="window.location='appiphone.html' " type="submit" /></li> <li class="button ipad"><input name="submit" value="app downloads" onclick="window.location='appipad.html' " type="submit" /></li> <li class="button android"><input name="submit" value="app downloads" onclick="window.location='appandroid.html' " type="submit" /></li> </ul> 

now have code redirects device specific page not want more.

<script type="text/javascript"> if (screen.width>801) { window.location="http://www.xclo.co.uk/pc.html" } </script> <script type="text/javascript"> // <![cdata[     if ( (navigator.useragent.indexof('android') != -1) ) {         document.location = "android.html";     } // ]]> </script> <script type="text/javascript">  var iphone = ((window.navigator.useragent.match('iphone'))||(window.navigator.useragent.match('ipod')))?true:false; var ipad = (window.navigator.useragent.match('ipad'))?true:false; if(iphone){  document.location = 'iphone.html'; } if(ipad){  document.location = 'ipad.html'; } </script> 

please can me in getting script display relevant content , not redirect.

thank you.

try this:

<ul class="pageitem">     <li class="button iphone" id="iphone"><input name="submit" value="app downloads" onclick="window.location='appiphone.html';" type="submit" /></li>      <li class="button ipad" id="ipad"><input name="submit" value="app downloads" onclick="window.location='appipad.html';" type="submit" /></li>      <li class="button android" id="android"><input name="submit" value="app downloads" onclick="window.location='appandroid.html';" type="submit" /></li> </ul> 

and

<script type="text/javascript">     function mayshowelement(id, shouldshow)     {         document.getelementbyid(id).style.display = shouldshow ? 'block' : 'none';     }      var useragent = window.navigator.useragent;      var mobile = {         is_iphone : useragent.match('iphone') || useragent.match('ipod'),         is_ipad   : useragent.match('ipad'),         is_iphone : useragent.indexof('android') != -1     };      mayshowelement('iphone', mobile.is_iphone);     mayshowelement('ipad', mobile.is_ipad);     mayshowelement('android', mobile.is_android); </script> 

this seems me solution (untested) based on code.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -