使用jQuery设置新窗口的大小 [英] Using jQuery to set the size of a new window

查看:113
本文介绍了使用jQuery设置新窗口的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery在新窗口中打开链接:

I am opening a link in a new window using jQuery:

<script type="text/javascript">
$(document).ready(function() {
    $('a[href="/education/global-health-courses"]').attr("target", "_blank");    
});
</script>

我想将新窗口的大小设置为800px宽乘700px高.我只需要一点帮助,即可将这些属性添加到现有代码中.

I would like to set the size of the new window to 800px wide by 700px tall. I just need a little help adding those attributes to the existing code.

谢谢.

推荐答案

您不能使用target="_blank"方法设置这些属性,而必须使用window.open方法:

You can't set those attributes using the target="_blank" method, you have to use the window.open method:

$(document).ready(function() {
    $('a[href="/education/global-health-courses"]').click(function() {
        window.open($(this).attr('href'),'title', 'width=800, height=700');
        return false;
    });   
});

这篇关于使用jQuery设置新窗口的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆