4Gの到着により、モバイルWebサイトは制御不能になり、PCとモバイルの公式Webサイトが共存しています。他の人にPCの公式Webサイトにアクセスして、モバイルWebサイトに直接ジャンプするにはどうすればよいですか?親愛なる読者、コードを追加してください!ここに来ます!
ブラウザが携帯電話であるかどうかを判断します
<script type = "text/javascript">(function(){var rewriteurl = function(url){if(url){var splits = url.split( "/")、sitename = window.location.pathname; if(typeof siteName!== "Undefined"){return "https://m.vevb.com"+sitename}}} pathname = windocy.location.pathname; if(url.indexof( "?pc")<0){try {window.location.href = rewriteurl(url)} catch(e){}}}})(); </script>ブラウザがPCであるかどうかを判断するには、PCページにジャンプします
<script> var browser1 = {versions:function(){var u = navigator.useragent、app = navigator.appversion; return {//モバイルターミナルブラウザーバージョン情報トライデント:U.indexof( 'Trident')> -1、// IEカーネルPresto:U.indexof( 'presto')> -1、// Opera Kernel webkit:U.indexof( 'Applewebkit')> -1、// AppleおよびGoogle Kernel Gecko:U.Undexo: u.indexof( 'khtml')== -1、// firefox kernel mobile:!! u.match(/applewebkit.*mobile/i)|| !! U.MATCH(/MIDP | SYMBIANOS | NOKIA | SAMSUNG | LG | NEC | TCL | ALCATEL | BIRD | DBTEL | DOPOD | HAIER | MOT- | NOKIA | SONYERICSSON | SIE- | AMOI | ZTE/)、// CPU。+Mac OS X/)、// iOSターミナルAndroid:U.indexof( 'Android') u.indexof( 'iPad')> -1、// iPad WebApp:U.Indexof( 'Safari')== -1 //は、プログラムされているWeb、ヘッダーとボトム}()、navigator.browserlanguage || navigator.language).tolowercase()} if(browser1.versions.mobile == false && browser1.versions.ios == false && browser1.versions.android == false && blowser1.versions.iphone == false && browser1.versions.ipad = = false.hef = location.href.Replace( "m以下は参照用のサプリメントです
jQueryは、ブラウザがモバイルまたはコンピューターベースのブラウザであるかどうかを決定します
小さなコード、同じウェブサイトがモバイルとコンピューターの視聴のために異なるページにジャンプします。
最初にjQueryファイルをロードします。
$(function(){var mobileua =(function(){var ua = navigator.useragent.tolowercase(); var mua = {ios:/pod -fone -pad/.test(ua)、// ios iphone:/phone/.test( /android/.test(ua)、// androidデバイスwindows:/windows/.test(ua)、// windowsデバイスtouch_device:( 'ontouchstart' in window)、// touchデバイス:/mobile/.test( Windows_tablet、// false、// tablet(ipad、android、windows:false // smart phone(iphone、android)}; mua.ipad || 'http://www.aaa.com/wap/index.html';Webページのデータ同期は携帯電話で必要です
コードコピーは次のとおりです。
<script type = "text/javascript">
(function(){var ua = navigator.useragent.tolowercase(); var bisipad = ua.match(/ipad/i)== "ipad"; var bisiphoneos = ua.match(/iiphone os/i)== "iphone os"; var bisandroid = ua.match(/android/i) "android/i) biswm = ua.match(/windows mobile/i)== "windows mobile"; if(bisipad || bisiphoneos || bisandroid || biswm){window.location.href = "http://m.vevb.com/android/game/826.html"}(})();
</script>
2番目の方法:
<スクリプト言語= "javascript"> function mobile_device_detect(url){var thisos = navigator.platform; var os = new Array( "iPhone"、 "iPod"、 "iPad"、 "android"、 "nokia"、 "symbianos"、 "symbian"、 "windows phone"、 "phone"、 "linux armv71"、 "maui"、 "strusted/1.0"、 "windows ce"、 "iemobile"); for(var i = 0; i <os.length; i ++){if(thisos.match(os [i])){window.location = url; }} //かなりの数の携帯電話システムが情報を知らないため、ここに一時的な特別な識別があります(navigator.platform.indexof( 'ipad')!= -1){window.location = url; } //この部分は、Android携帯のカーネルもLinux //であるためですが、navigator.platformは異なる情報を表示するため、ブラウザから始めます。つまり、Navigator.Appversion情報を使用してJudgents var check = navigator.appversion; if(check.match(/linux/i)){// x11はUCブラウザーのプラットフォームです。他の特別なブラウザがある場合は、条件を添付することもできます(check.match(/mobile/i)|| check.match(/x11/i)){window.location = url; }} // class in_array function array.prototype.in_array = function(e){for(i = 0; i <this.length; i ++){if(this [i] == e)return true; } falseを返します。 }} mobile_device_detect( "http://***.**.com"); </script>ここに注意してください
mobile_device_detect( "http://***.***.com"); //内部のアドレスはモバイルWebサイトアドレスに記入されています。