我正在使用 jQuery 在新窗口中打开链接:
<script type="text/javascript">
$(document).ready(function() {
$('a[href="/education/global-health-courses"]').attr("target", "_blank");
});
</script>
我想将新窗口的大小设置为 800 像素宽 x 700 像素高。我只需要一点帮助将这些属性添加到现有代码中。
谢谢。
最佳答案
您无法使用 target="_blank"
方法设置这些属性,您必须使用 window.open 方法:
$(document).ready(function() {
$('a[href="/education/global-health-courses"]').click(function() {
window.open($(this).attr('href'),'title', 'width=800, height=700');
return false;
});
});
关于jquery - 使用 jQuery 设置新窗口的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2096363/