QQ、微信跳转浏览器打开


$_SERVER['HTTP_USER_AGENT']主要靠php获取浏览器参数,判断是否QQ、微信,如果是就跳转。QQ只有.com和.cn能自动跳转!!!

<?php
$scriptpath = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']);
$sitepath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
$siteurl = ($_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $sitepath . '/';
if (strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== !1 ) {
echo '<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>请使用浏览器打开</title>
  <script src="https://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script>
  <script type="text/javascript"> mqq.ui.openUrl({ target: 2,url: "' . $siteurl . '"}); </script>
	<style>
      body,html{width:100%;height:100%}
      *{margin:0;padding:0}
      body{background-color:#fff}
      .top-bar-guidance{font-size:15px;color:#fff;height:40%;line-height:1.8;padding-left:20px;padding-top:20px;background:url(https://gw.alicdn.com/tfs/TB1eSZaNFXXXXb.XXXXXXXXXXXX-750-234.png) center top/contain no-repeat}
      .top-bar-guidance .icon-safari{width:25px;height:25px;vertical-align:middle;margin:0 .2em}
      .app-download-btn{display:block;width:214px;height:40px;line-height:40px;margin:18px auto 0 auto;text-align:center;font-size:18px;color:#2466f4;border-radius:20px;border:.5px #2466f4 solid;text-decoration:none}
	</style>

 </head>
 <body>

	<div class="top-bar-guidance">
		<p>
			点击右上角<img src="https://gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari"/> Safari打开
		</p>
		<p>
			可以继续访问本站哦~
		</p>
	</div>
 </body>
</html>';
exit;
}else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger/') !== !1 ) {
	header("Content-Disposition: attachment; filename=\"load.doc\"");
	header("Content-Type: application/vnd.ms-word;charset=utf-8"); 
  echo'<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>请使用浏览器打开</title>
  <script src="https://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script>
  <script type="text/javascript"> mqq.ui.openUrl({ target: 2,url: "' . $siteurl . '"}); </script>
	<style>
      body,html{width:100%;height:100%}
      *{margin:0;padding:0}
      body{background-color:#fff}
      .top-bar-guidance{font-size:15px;color:#fff;height:40%;line-height:1.8;padding-left:20px;padding-top:20px;background:url(https://gw.alicdn.com/tfs/TB1eSZaNFXXXXb.XXXXXXXXXXXX-750-234.png) center top/contain no-repeat}
      .top-bar-guidance .icon-safari{width:25px;height:25px;vertical-align:middle;margin:0 .2em}
      .app-download-btn{display:block;width:214px;height:40px;line-height:40px;margin:18px auto 0 auto;text-align:center;font-size:18px;color:#2466f4;border-radius:20px;border:.5px #2466f4 solid;text-decoration:none}
	</style>

 </head>
 <body>

	<div class="top-bar-guidance">
		<p>
			点击右上角<img src="https://gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari"/> Safari打开
		</p>
		<p>
			可以继续访问本站哦~
		</p>
	</div>
 </body>
</html>';
  exit;
}else{
echo '<script language="javascript" type="text/javascript">
	window.location.href="http://www.baidu.com";
</script>';
}
?>

1.png

none

发表评论

0条评论

设置
配色方案

布局

现在购买