Chrome:window.open会打开新标签而不是新的弹出窗口

时间:2017-06-21 05:14:26

标签: javascript google-chrome popupwindow

我有这个片段:

HTML

<a href="#" class="option-link" data-url="https://www.google.com">CLICK ME</a>

JS

var popup = undefined;

// Option links toggle
$('.option-link').on('click', function (e) {

    e.preventDefault();

    var url = $(this).data('url');

    if (typeof url !== 'undefined' && url) {

        function __popup_open(link) {
            return window.open(
                link, 
                'same_window',
                'width = 940, height = 620, toolbar = 0, menubar = 0, location = 1, status = 1, scrollbars = 0, resizable = 0, left = 0, top = 0'
            );
        }


        if (typeof popup == 'undefined' || popup.closed) {

            popup = __popup_open(url);

        } else {

            popup.close();
            popup = __popup_open(url);
        }

        popup.focus();
    }

});

从v58(58.0.3029.110)向后运行旧版Chrome的脚本将提供打开新弹出窗口的正确行为。

但是在我将浏览器更新到v59(59.0.3071.104)之后,它打开了一个新的浏览器选项卡,而不是打开一个弹出窗口。

这是浏览器本身的问题吗?或者我的代码中的某些内容使其无法正常工作,只要此处的唯一更改是浏览器版本。

PS 尝试使用Mozilla的这个代码片段可以正常工作。

1 个答案:

答案 0 :(得分:1)

Chrome不再喜欢Include(x => x.Privileges) .Include(x => x.Team.Branch) .Include(x => x.Equality) .Include(x => x.AddressDetails).Include(x => x.ContactDetails) .Include(x => x.EmployeeDetails.GeneralUnavailability) .Include(x => x.EmployeeDetails.EligibilityDocuments.Select(z => z.Document.Priviliges)) .Include(x => x.EmployeeDetails.Position.PositionPayRuleExceptions).Include(x => x.EmployeeDetails.Position.PositionPayRuleExceptions.Select(z => z.PayRule)).Include(x => x.EmployeeDetails.Position.DefaultOffer) .Include(x => x.TransportationMode.ProofOfLicence.Priviliges).Include(x => x.TransportationMode.ProofOfInsurance) .Include(x => x.UserAcademicQualifications.Select(z => z.AcademicQualification)).Include(x => x.UserAcademicQualifications.Select(z => z.AcademicQualificationScan.Priviliges)) .Include(x => x.ProfessionalRegistrations.Select(z => z.Body)).Include(x => x.ProfessionalRegistrations.Select(z => z.ProfessionalRegistrationScan.Priviliges)) .Include(x => x.Unavailabilities.Select(z => z.AbsenceType)).Include(x => x.Unavailabilities.Select(z => z.Document.Priviliges)) .Where(x=>x.Id=1) 来打开弹出广告。

将其更改为location=1location=0,您就可以了。

从规格 https://www.w3schools.com/jsref/met_win_open.asp

位置yes仅在Opera中使用。