使用jQuery设置新窗口的大小
我正在使用jQuery在新窗口中打开链接:使用jQuery设置新窗口的大小,jquery,Jquery,我正在使用jQuery在新窗口中打开链接: <script type="text/javascript"> $(document).ready(function() { $('a[href="/education/global-health-courses"]').attr("target", "_blank"); }); </script> $(文档).ready(函数(){ $('a[href=“/education/global health c
<script type="text/javascript">
$(document).ready(function() {
$('a[href="/education/global-health-courses"]').attr("target", "_blank");
});
</script>
$(文档).ready(函数(){
$('a[href=“/education/global health courses”]).attr(“target”,_blank);
});
我想将新窗口的大小设置为800px宽700px高。我只是需要一些帮助,将这些属性添加到现有代码中
谢谢。要设置窗口大小,需要使用方法。您可以订阅
单击事件并调用窗口,而不是在锚上使用target=“\u blank”
。打开您无法调整目标=blank
窗口的大小
您必须使用窗口创建一个新窗口。打开-如in-并添加测试窗口。重新设置(x,y)
命令以确保。您不能使用目标=“\u blank”
方法设置这些属性,您必须使用窗口。打开方法:
$(document).ready(function() {
$('a[href="/education/global-health-courses"]').click(function() {
window.open($(this).attr('href'),'title', 'width=800, height=700');
return false;
});
});
一种很好的方法是使用带有colorbox()的iframe
如果您真的想要非常好地控制外观和行为,我强烈建议您使用名为的脚本。它是最稳定和通用的模式窗口javascript脚本。您可以使用该脚本在弹出div(包含iframe)中启动外部页面。@fmz:您可以在此处找到窗口的所有选项。open方法:
$('a[href="/education/global-health-courses"]')
.colorbox({width:"80%", height:"80%", iframe:true});