Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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_Popupwindow - Fatal编程技术网

Javascript jQuery函数在新窗口中打开链接

Javascript jQuery函数在新窗口中打开链接,javascript,jquery,popupwindow,Javascript,Jquery,Popupwindow,我试图找到一个插件或简单的脚本,通过点击按钮在弹出窗口中打开一个文件。这以前是可以工作的,但是对于所有jQuery更新(即使是迁移文件),这已经不起作用了 我找到了这个,但这会打开弹出窗口并重定向到文件url: $(document).ready(function() { $('.popup').click(function(event) { window.open($(this).attr("href"), "popupWindow", "width=600,height=600,sc

我试图找到一个插件或简单的脚本,通过点击按钮在弹出窗口中打开一个文件。这以前是可以工作的,但是对于所有jQuery更新(即使是迁移文件),这已经不起作用了

我找到了这个,但这会打开弹出窗口并重定向到文件url:

$(document).ready(function() {
$('.popup').click(function(event) {
    window.open($(this).attr("href"), "popupWindow", "width=600,height=600,scrollbars=yes");
 });
});
有没有办法得到一个简单的弹出窗口?它需要有滚动条,最好是可调整大小的。我看过很多关于模态盒的帖子,但这并不能满足我的需要。弹出框有它自己的设计,并且有更多的内容,不适合模式

我还希望避免添加任何额外的标记。只添加一个类是最有意义的,如上面的示例。

试试这个

$('.popup').click(function(event) {
    event.preventDefault();
    window.open($(this).attr("href"), "popupWindow", "width=600,height=600,scrollbars=yes");
});
必须包含jQuery引用才能执行此操作, 这是工作样本

尝试添加
返回false在您的单击回调中,如下所示-

$(document).ready(function() {
  $('.popup').click(function(event) {
      window.open($(this).attr("href"), "popupWindow", "width=600,height=600,scrollbars=yes");
      return false;
  });
});

仅按钮单击事件

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
        <script language="javascript" type="text/javascript">
            $(document).ready(function () {
                $("#btnext").click(function () {                    
                    window.open("HTMLPage.htm", "PopupWindow", "width=600,height=600,scrollbars=yes,resizable=no");
                });
            });
</script>

$(文档).ready(函数(){
$(“#btnext”)。单击(函数(){
open(“HTMLPage.htm”,“PopupWindow”,“宽度=600,高度=600,滚动条=yes,可调整大小=no”);
});
});


@jenhan您是否有被阻止的弹出窗口?没有,我已经检查过了,它们没有被阻止。@jenhan:查看示例SharedHanks Chamika。我确实引用了jQuery。我认为这是一个IE问题。它在Chrome和Firefox中工作。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
        <script language="javascript" type="text/javascript">
            $(document).ready(function () {
                $("#btnext").click(function () {                    
                    window.open("HTMLPage.htm", "PopupWindow", "width=600,height=600,scrollbars=yes,resizable=no");
                });
            });
</script>
$(document).ready(function() {
$('A.BLAH').click(function() {
var NWin = window.open($(this).prop('href'), '', 'height=600,width=1000');
if (window.focus)
{
NWin.focus();
}
return false;
});
});