IE browser detect and redirect

by thedog
4 replies
Hi guys. I want any users, using IE, to be redirected to a certain page on my site.

I installed this plugin, PHP Browser Detection WordPress › PHP Browser Detection « WordPress Plugins

and put the following code in my head tag, in header.php


<?php if ( is_IE ) { <meta http-equiv="refresh" content="0;url=http://www.site.com/test.html" /> }; ?>

I also tried this, but no joy,

<?php if ( is_IE ) { window.location="http://www.yourdomain.com/redirectfile.html"; }; ?>




I just got an error code.

Can someone please tell me the best way to do this, thanks.
#browser #detect #redirect
  • Profile picture of the author SteveJohnson
    You're not calling the function correctly. Should be:
    Code:
    <?php if( is_IE() ) { do stuff here // } ?>
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[3696991].message }}
    • Profile picture of the author thedog
      Originally Posted by SteveJohnson View Post

      You're not calling the function correctly. Should be:
      Code:
      <?php if( is_IE() ) { do stuff here // } ?>
      ok, i tried this

      <?php if( is_IE() ) { window.location="http://www.site.com/test.html"; // } ?>

      and it didn't work...

      if this is wrong, can you please paste exactly what i need to be doing, thanks.
      {{ DiscussionBoard.errors[3697619].message }}
  • Profile picture of the author AdFocus
    your syntax is incorrect

    try:

    Code:
    <?php if ( is_IE ) { ?>
    <meta http-equiv="refresh" content="0;url=http://www.site.com/test.html" />
    <?php } ?>
    {{ DiscussionBoard.errors[3701710].message }}
    • Profile picture of the author thedog
      Thanks, I ended up using this script I found online, it works, but do you think it's ok?


      <script>version=parseInt(navigator.appVersion);i f (navigator.appVersion.indexOf('5.')>-1){version=5};if (navigator.appVersion.indexOf('6.')>-1){version=6}; if (navigator.appVersion.indexOf('7.')>-1){version=7}; browser='OTHER'; if (navigator.appName=='Netscape'){browser='NS'+versi on;} if (navigator.appName=='Microsoft Internet Explorer'){browser='MSIE'+version;} if (navigator.appVersion.indexOf('MSIE 3')>0) {browser='MSIE3';} if(browser == 'NS5'){browser='NS6'};if (browser=='MSIE3') {window.location='http://www.site.com/ie-chrome-frame/'}if (browser=='MSIE4') {window.location='http://www.site.com/ie-chrome-frame/'}if (browser=='MSIE5') {window.location='http://www.site.com/ie-chrome-frame/'}if (browser=='MSIE6') {window.location='http://www.site.com/ie-chrome-frame/'}if (browser=='MSIE7'){window.location='http://www.site.com/ie-chrome-frame/'}if (browser=='MSIE8'){window.location='http://www.site.com/ie-chrome-frame/'}if (browser=='MSIE9'){window.location='http://www.site.com/new/'}if (browser=='NS3') </script>
      {{ DiscussionBoard.errors[3702474].message }}

Trending Topics