cdooo
非常火狐
非常火狐
  • UID8445
  • 注册日期2005-09-07
  • 最后登录2017-02-26
  • 发帖数932
  • 经验29枚
  • 威望0点
  • 贡献值18点
  • 好评度1点
  • 社区居民
  • 忠实会员
阅读:1468回复:0

Some Php Http_user_agent Header Redirect, Firefox-only.(zz)

楼主#
更多 发布于:2006-08-06 01:27
Cool:
<?php
//Firefox-only redirect.
$from = getenv("HTTP_USER_AGENT");
if (strpos($from,'Firefox') != true ) {
//If it's not Firefox, redirect:
Header ("Location: http://nostromo.no.funpic.org/");
exit;
}
//Else if Firefox, then run the rest of the page :)
echo('HTTP_USER_AGENT contained Firefox');
?>


phpBB:
<div class="copyright">
<a href="http://www.spreadfirefox.com/?q=affiliates&id=66183&t=86" target="top" class="copyright" style="text-decoration: none;" >
<script type="text/javascript">
<!--
useragent=navigator.userAgent.toUpperCase();
pos=useragent.indexOf("FIREFOX");
if(pos>=0)
{document.write("You're currently using Mozilla Firefox!");}
if(pos<0)
{document.write("Tried using Firefox? rediscover the web!");}
//-->
</script>
</a>
</div>


Website
<a href="http://www.spreadfirefox.com/?q=affiliates&id=66183&t=86" target="top" class="copyright" style="text-decoration: none;" >
<script type="text/javascript">
<!--
useragent=navigator.userAgent.toUpperCase();
pos=useragent.indexOf("FIREFOX");
if(pos>=0)
{document.write("You're currently using Mozilla Firefox!");}
if(pos<0)
{document.write("Tried using Firefox? rediscover the web!");}
//-->
</script>
</a>


In javascript you can use the navigator.appName feature to get the actual name of the browser
As in:
<script language="javascript">
document.write("You are using "+navigator.appName+".");
</script>


or
<script language="javascript">
var browser=navigator.appName;
if(browser=="Firefox") window.location.href = "firefoxpage.html";
</script>


Browser detection should be done with JavaScript, because some browser can and do send an invalid or false identifier.
ccc
游客

返回顶部