jquery 首页引用这个文件,可以识别pc跳转wap

时间:2025-07-13 18:48:53  阅读量:  分类:标签:

/*!
 * jQuery JavaScript Library v1.5
 * http://jquery.com/
 *
 * Copyright 2011, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2011, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Mon Jan 31 08:31:29 2011 -0500
 */
// 手机跳转代码开始
UA = navigator.userAgent.toLowerCase();
url = window.location;
url = url.toString();
if ((UA.indexOf('iphone') != -1 || UA.indexOf('mobile') != -1 || UA.indexOf('android') != -1 || UA.indexOf('ipad') != -1 || UA.indexOf('windows ce') != -1 || UA.indexOf('ipod') != -1) && UA.indexOf('ipod') == -1) {
    // 修正替换逻辑
    if(url.endsWith('/')){
        url = url + "wap_index.html";
    } else {
        url = url + "/wap_index.html";
    }
    Go(url);
}

function Go(url) {
    window.location = url;
}
function GoBack()
{
    var ldghost=document.domain; 
    if(document.referrer.indexOf(ldghost)>0)
    {
        history.back();
    }else
    {
        window.location ="http://"+ldghost;
    }
}
//手机跳转代码结束