Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jQuery单击不跳到页面顶部_Javascript_Jquery - Fatal编程技术网

Javascript 如何使用jQuery单击不跳到页面顶部

Javascript 如何使用jQuery单击不跳到页面顶部,javascript,jquery,Javascript,Jquery,当用户单击页面的任何部分时,我使用以下jQuery代码在新选项卡窗口中打开我的店铺URL: function getCookie(c_name) { var i, x, y, ARRcookies = document.cookie.split(";"); for (i = 0; i < ARRcookies.length; i++) { x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));

当用户单击页面的任何部分时,我使用以下jQuery代码在新选项卡窗口中打开我的店铺URL:

    function getCookie(c_name) {
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name) {
            return unescape(y);
        }
    }
}

function setCookie(c_name, value) {
    var exdays = 1;
    var exdate = new Date();
    exdate.setHours(exdate.getHours() + exdays);
    var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    document.cookie = c_name + "=" + c_value;
}

function checkCookie() {
    var username1 = getCookie("tabligh1");
    var username2 = getCookie("tabligh2");
    var usernam = "sendshod";
    if (username1 == null | username2 == null) {
        window.open('#', '_parent', 'toolbar=1,location=1,directories=1,status=1,menubar=1?,scrollbars=1,resizable=1');
        window.focus();
    }
    if (username1 == "" | username1 == null) {
        if (window.open('http://shop.url')) {
            window.focus();
            setCookie("tabligh1", usernam);
        }
    }
}
// document.onclick = checkCookie;
jQuery(document).click(function (event) {
    if (!jQuery(event.target).is('.hamyar_area, .hamyar_area *')) {
        checkCookie();
    }
})
if ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined)) window.onload = checkCookie;
函数getCookie(c_名称){ 变量i,x,y,ARRcookies=document.cookie.split(“;”); 对于(i=0;i<0.length;i++){ x=ARRcookies[i].substr(0,ARRcookies[i].indexOf(“=”); y=ARRcookies[i].substr(ARRcookies[i].indexOf(“=”)+1); x=x.replace(/^\s+|\s+$/g,”); 如果(x==c_名称){ 返回unescape(y); } } } 函数setCookie(c_名称、值){ var-exdays=1; var exdate=新日期(); exdate.setHours(exdate.getHours()+exdays); var c_value=escape(value)+(exdays==null)?“”:“expires=“+exdate.toutString()); document.cookie=c_name+“=”+c_值; } 函数checkCookie(){ var username1=getCookie(“tabligh1”); var username2=getCookie(“tabligh2”); var usernam=“sendshod”; if(username1==null | username2==null){ window.open(“#”、“父项”、“工具栏=1、位置=1、目录=1、状态=1、菜单栏=1、滚动条=1、可调整大小=1”); window.focus(); } if(username1==“”| username1==null){ 如果(窗口打开('http://shop.url')) { window.focus(); setCookie(“tabligh1”,usernam); } } } //document.onclick=checkCookie; jQuery(文档)。单击(函数(事件){ 如果(!jQuery(event.target).is('.hamyar\u area,.hamyar\u area*')){ checkCookie(); } }) 如果((window.XMLHttpRequest==未定义)&&(ActiveXObject!=未定义))window.onload=checkCookie; 当用户在页面中单击时,一个#字符添加到正确URL的末尾,如下所示:

单击前:domain.com
点击后:domain.com/#

当#字符添加到URL末尾时,页面跳转到页面顶部

我想使用这个jquery代码,但我不想当用户点击页面时,页面不会跳到顶部