is there a PHP code/script that will detect what browser the user is using, and then depending which browser is using, print a message onto the pae (not as a pop-up message, but actually on the page itself) ?
like, i want to have the page write a message onto the website if the user is using netscape. is there a php that can do this? or do i use javascript?Wow.. de ja vu lol (I just answered a thread very similar to this).
This is done in javascript (not PHP as PHP is server side not client side).
place this in the <head></head> section
<script language="Javascript" type='text/Javascript'>
<!--
if (navigator.appName=="Microsoft Internet Explorer")
document.write("TEXT FOR IE USERS");
else if (navigator.appName=="Netscape")
document.write("TEXT FOR NETSCAPE USERS");
//-->
</script>
You can of course take it one step further to do a check for browser versions and print different text for that if you wanted.in php u can use $_SERVER['HTTP_USER_AGENT'] environment variable.
eg if (eregi("MSIE",$_SERVER['HTTP_USER_AGENT'])) {
//code for IE users goes here
}
else {
//code for non ie user
}Originally posted by jollyfactory
Wow.. de ja vu lol (I just answered a thread very similar to this).
This is done in javascript (not PHP as PHP is server side not client side).
place this in the <head></head> section
<script language="Javascript" type='text/Javascript'>
<!--
if (navigator.appName=="Microsoft Internet Explorer")
document.write("TEXT FOR IE USERS");
else if (navigator.appName=="Netscape")
document.write("TEXT FOR NETSCAPE USERS");
//-->
</script>
You can of course take it one step further to do a check for browser versions and print different text for that if you wanted.
nah, i just needed it for netscape only .... my webpage doesnt seem to view well on netscape at all ... so i planned on having a popup (for the 1st time visitor only, doesnt popup after that) and in that popup would be a welcome message ... but if the person was using netscape, i wanted to print a warning message about using netscape ....
in php u can use $_SERVER['HTTP_USER_AGENT'] environment variable.
eg if (eregi("MSIE",$_SERVER['HTTP_USER_AGENT'])) {
//code for IE users goes here
}
else {
//code for non ie user
}
so the code would look like this:
<?
if (eregi("MSIE",$_SERVER['HTTP_USER_AGENT'])) {
<p style="blah">IE message</p>
}
else {
<p style="blah">Netscape message</p>
}
?>
(i forgot the opening and closing variables for PHP...but i think you get it ...)
is that it?i just posted a script here (<!-- m --><a class="postlink" href="http://htmlforums.com/showthread.php?s=&threadid=21283">http://htmlforums.com/showthread.php?s=&threadid=21283</a><!-- m -->).
like, i want to have the page write a message onto the website if the user is using netscape. is there a php that can do this? or do i use javascript?Wow.. de ja vu lol (I just answered a thread very similar to this).
This is done in javascript (not PHP as PHP is server side not client side).
place this in the <head></head> section
<script language="Javascript" type='text/Javascript'>
<!--
if (navigator.appName=="Microsoft Internet Explorer")
document.write("TEXT FOR IE USERS");
else if (navigator.appName=="Netscape")
document.write("TEXT FOR NETSCAPE USERS");
//-->
</script>
You can of course take it one step further to do a check for browser versions and print different text for that if you wanted.in php u can use $_SERVER['HTTP_USER_AGENT'] environment variable.
eg if (eregi("MSIE",$_SERVER['HTTP_USER_AGENT'])) {
//code for IE users goes here
}
else {
//code for non ie user
}Originally posted by jollyfactory
Wow.. de ja vu lol (I just answered a thread very similar to this).
This is done in javascript (not PHP as PHP is server side not client side).
place this in the <head></head> section
<script language="Javascript" type='text/Javascript'>
<!--
if (navigator.appName=="Microsoft Internet Explorer")
document.write("TEXT FOR IE USERS");
else if (navigator.appName=="Netscape")
document.write("TEXT FOR NETSCAPE USERS");
//-->
</script>
You can of course take it one step further to do a check for browser versions and print different text for that if you wanted.
nah, i just needed it for netscape only .... my webpage doesnt seem to view well on netscape at all ... so i planned on having a popup (for the 1st time visitor only, doesnt popup after that) and in that popup would be a welcome message ... but if the person was using netscape, i wanted to print a warning message about using netscape ....
in php u can use $_SERVER['HTTP_USER_AGENT'] environment variable.
eg if (eregi("MSIE",$_SERVER['HTTP_USER_AGENT'])) {
//code for IE users goes here
}
else {
//code for non ie user
}
so the code would look like this:
<?
if (eregi("MSIE",$_SERVER['HTTP_USER_AGENT'])) {
<p style="blah">IE message</p>
}
else {
<p style="blah">Netscape message</p>
}
?>
(i forgot the opening and closing variables for PHP...but i think you get it ...)
is that it?i just posted a script here (<!-- m --><a class="postlink" href="http://htmlforums.com/showthread.php?s=&threadid=21283">http://htmlforums.com/showthread.php?s=&threadid=21283</a><!-- m -->).