IE browser detect and redirect

by 4 replies
7
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.
#programming #browser #detect #redirect
  • You're not calling the function correctly. Should be:
    Code:
    <?php if( is_IE() ) { do stuff here // } ?>
    • [1] reply
    • 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.
  • your syntax is incorrect

    try:

    Code:
    <?php if ( is_IE ) { ?>
    <meta http-equiv="refresh" content="0;url=http://www.site.com/test.html" />
    <?php } ?>
    • [1] reply
    • 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>

Next Topics on Trending Feed

  • 7

    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