function clickwebcast(_a, id, ptitle, ptype) {            var url = '*****' + '?' + Math.random();
            var user = '****';
            var u = '****';
            if (user == null || user.length == 0) {
                alert("登录后才能观看!");
                $(".gts_download").hide();
                $(".filter").show(); $(".gts_logindiv").css("visibility", "visible");
                scroll(0, 0);
                return false;
            } else {
                _a.setAttribute("onclick", '');
                $.get(
                    url,
                    { id: id, pagetitle: ptitle, pagetype: ptype },
                    function (data) {
                        if (data.OK) {
                            _a.href = data.Url + u;
                            _a.click("return true");
                        }
                    });
                return false
            }
        }<a href="javascript:void(0);" onclick="return clickwebcast(this,Id,'PageTitle','***')" target="_blank">原本要实现的功能是用户在页面上点击一个链接,然后去往另一个网站上观看视频,但是必须先登录。然后就有了上面的方法,但是现在出现了一个问题就是浏览器有时候会提示 已拦截xxx网站弹出的页面。
能不能规避一下不让浏览器出现这中提示?
或者你们有更好的方法?

解决方案 »

  1.   

    url的链接是需要根据id 去后台数据库中查询的,现在想到的一个方法是 直接将链接显示在参数中,就不用去后台数据获取url了。试试看吧。
      

  2.   

    用下面这个    function clickwebcast(_a, id, ptitle, ptype) {        var url = '*****' + '?' + Math.random();
            var user = '****';
            var u = '****';
            if (user == null || user.length == 0) {
                alert("登录后才能观看!");
                $(".gts_download").hide();
                $(".filter").show(); $(".gts_logindiv").css("visibility", "visible");
                scroll(0, 0);
                return false;
            } else {
                //_a.setAttribute("onclick", '');
                $.ajax({ type: 'GET', url: url, data: { id: id, pagetitle: ptitle, pagetype: ptype }
                ,async:false///////改为同步
                , success: function (data) {
                    if (data.OK) {
                        _a.href = data.Url + u;
                        //_a.click("return true");
                    }
            } });
               /* $.get(
                        url,
                        { id: id, pagetitle: ptitle, pagetype: ptype },
                        function (data) {
                            if (data.OK) {
                                _a.href = data.Url + u;
                                //_a.click("return true");
                            }
                        });*/
                return true
            }
        }
      

  3.   

    把跳转连接写到onclick事件中,用open打开新页面;href=“###”