Jump to content

Brower detection in Javascript.


Fsoft

Recommended Posts

Hello,

 

I need a small help :(, I used this fuction :

function get_user_browser() 
{ 


    $u_agent = $_SERVER['HTTP_USER_AGENT']; 
    $ub = ''; 
    if(preg_match('/MSIE/i',$u_agent)) 
    { 
        $ub = "ie"; 
    } 
    elseif(preg_match('/Firefox/i',$u_agent)) 
    { 
        $ub = "firefox"; 
    } 
    elseif(preg_match('/Safari/i',$u_agent)) 
    { 
        $ub = "safari"; 
    } 
    elseif(preg_match('/Chrome/i',$u_agent)) 
    { 
        $ub = "chrome"; 
    } 
    elseif(preg_match('/Flock/i',$u_agent)) 
    { 
        $ub = "flock"; 
    } 
    elseif(preg_match('/Opera/i',$u_agent)) 
    { 
        $ub = "opera"; 
    } 
    
    return $ub; 
}


$browser = get_user_browser();

if($browser == "ie")
{

}else
{ 
echo "<center><b>Sorry but our system says that you are not using Microsoft Internet Explorer.<br> You can not access this with any other browser.. <br>You must use Internet explorer to explore this site.. <br>Thanks for understanding, Please try again later with Internet Explorer.</b></center>";
exit();
}

 

This function I found on php.net while searching for a good function of browser detection, the problem is due to some reasons I want my site to open in Only Internet explorer.

 

It seemed to work totally nice and correctly, all the browsers used to show error else then IE.

 

But my friend just installed a plugin available for firefox, using that you can make your firefox IE, which means all the scripts will think your browser is IE but actually it is firfox :(

 

SO this function actually failed :(..

 

I want to know if there is a good simple function in JAVASCRIPT which can detect if browser is IE or not?

 

Please help, I am null in javascript, never did. Please help.

 

Thank you very much...

 

Link to comment
Share on other sites

 

 

This function I found on php.net while searching for a good function of browser detection, the problem is due to some reasons I want my site to open in Only Internet explorer.

Why I can't imagine any good reason for blocking a type of browser.

But my friend just installed a plugin available for firefox, using that you can make your firefox IE, which means all the scripts will think your browser is IE but actually it is firfox :(

 

 

That must be the user agent switcher for firefox I love that plugin for websites that block firefox. But fixing this in javascript won't help you resolve this.

Link to comment
Share on other sites

 

 

This function I found on php.net while searching for a good function of browser detection, the problem is due to some reasons I want my site to open in Only Internet explorer.

Why I can't imagine any good reason for blocking a type of browser.

But my friend just installed a plugin available for firefox, using that you can make your firefox IE, which means all the scripts will think your browser is IE but actually it is firfox :(

 

 

That must be the user agent switcher for firefox I love that plugin for websites that block firefox. But fixing this in javascript won't help you resolve this.

 

here is the reason : http://www.phpfreaks.com/forums/index.php/topic,264100.0.html

Link to comment
Share on other sites

It might be a reason but it's still not a GOOD reason. Besides that there is simply no way to fully make sure what browser someone is using other then that forcing someone to use IE isn't an option. And even if you can only view a page in IE you can still get the video which is mentioned to you earlier.

 

You might also want to view the following thread:

http://www.phpfreaks.com/forums/index.php/topic,248798.0.html

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.