Jump to content

sniff for IE and use different function?


tqla

Recommended Posts

Hello. I am using the following popup script. It looks great in FF but it opens wider in IE. Is there a way to sniff the browser and then use a different popup function in IE?

 

<SCRIPT LANGUAGE="JavaScript">
function popup(w,h,p){
var left = (screen.availWidth/2) - (w/2);
var top = (screen.availHeight/2) - (h/2);
window.open(p,'Insert','width='+w+',height='+h+',scrollbars=0,status=0,menubar=0 left='+left+', top='+top)
}
</SCRIPT>

 

 

<A HREF="javascript:popup(150,400,'selector.php')" >This will be the link</A> 

Link to comment
https://forums.phpfreaks.com/topic/195847-sniff-for-ie-and-use-different-function/
Share on other sites

Figured it out. First I check the browser with PHP

 

<?php
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ){ 
$b = "javascript:popup(120,400,'selector.php')"; 
}else{
$b = "javascript:popup(150,400,'selector.php')";
}
?>

 

Then I echo into my href

 

<A HREF="<?php echo $b; ?>" >This will be the link</A> 

 

bingo!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.