码迷,mamicode.com
首页 > Web开发 > 详细

a标签的href劫持,做判断后在跳转

时间:2014-10-21 19:28:12      阅读:1433      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   ar   使用   java   sp   

$.ajax({
               type: "POST",
               url: "/resource/logincheck",
               data: {id: id},
               success: function(data){
                    if (data.ok == 1) {
                        var href_url = dl_link[dlt];
                        if(opentype == 1){
                            window.location.href = href_url;
                        }else if(opentype == 2){
                            //火狐下无法实现模拟点击
                            $(that).attr(href,href_url);
                            $(that).attr(target,_blank);
                  setTimeout(function(){repl(that);},1000);
return true; }else{ chwTip(无法下载); return false; } } else if (data.ok == 0) { if (data.error == 1) { chwTip(请先登录); return false; } else if (data.error == 3) { chwTip(参数错误); return false; } } }, async:false });

function repl(that){
        $(that).attr(‘href‘,‘javascript:void(0);‘);
        $(that).removeAttr(‘target‘);
    }

火狐下无法模拟超链接点击,使用window.open和其他的形式都会被提示阻止。这里必须同步执行。

a标签的href劫持,做判断后在跳转

标签:style   blog   color   io   os   ar   使用   java   sp   

原文地址:http://www.cnblogs.com/kudosharry/p/4040837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!