简体   繁体   English

javascript window.open无法在IE中运行

[英]javascript window.open is not working in IE

I want link to be open in new window but when i click on write_review in IE it is opening in new tab. 我希望链接在新窗口中打开,但是当我在IE中单击write_review时,它将在新选项卡中打开。 I have checked for spaces in the arguments which are causing the problem. 我检查了导致问题的参数中的空格。 But no problem with that. 但没问题。

I have checked on URL :- Javascript window.open is blocked by IE popup blocker 我已检查过URL: - Javascript window.open被IE弹出窗口拦截器阻止

But its not working for me.. 但它不适合我..

This is my working code in another browser. 这是我在另一个浏览器中的工作代码。

    // Opening pop-up window for the write review
    jQuery('a#write_review').click(function() {
        var w = 1000;
        var h = 650;
        var left = (screen.width/2)-(w/2);
        var top = (screen.height/2)-(h/2);
        var planid=$(this).parent().parent().find('input[name="data[PlanIdsel]"]').val();
        var providerid=$(this).parent().parent().find('input[name="data[ProviderIdsel]"]').val();
        var rep=$(this).parent().parent().find('input[name="data[Repsel]"]').val();
        var url = "<?php echo $this->webroot ?>"+"enrollments/write_rating/"+planid+"?Rep="+rep+"&providerId="+providerid;
        window.open(url, 'subWind', 'status, scrollbars, resizable, dependent, width='+w+', height='+h+', left='+left+', top='+top);
    });

Please guide me or correct me.. 请指导我或纠正我..

check this How do you get window.open to work in internet explorer 7? 检查这个如何让window.open在Internet Explorer 7中工作?

This is part of the security changes made in IE6. 这是IE6中进行的安全性更改的一部分。 Now you can only call "window.open" from within a user-initiated event. 现在,您只能在用户启动的事件中调用“window.open”。 For example, your code would work inside an element's onclick event. 例如,您的代码将在元素的onclick事件中起作用。 The "window.open" MSDN page says this “window.open”MSDN页面说明了这一点

link 链接

$(document).ready(function(){
  $("a#ID of your link").click(function(){
    var w = 1000;
    var h = 650;
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var url = "your url";
    window.open(url, 'subWind', 'status, scrollbars, resizable, dependent, width='+w+', height='+h+', left='+left+', top='+top);
  });
});

this should work. 这应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM