我正在使用 jquery UI 对话框,并且有一些单选按钮和一个提交按钮。
如果选择第一个按钮,并且用户单击该按钮,我希望打开一个新窗口,就像有一个 href 标签一样:
<a href="http://www.example.com" target="_blank">Click</a>
到目前为止,在点击事件中我处于:
$(this).click(function (e) {
e.preventDefault();
});
可以这样做吗? (必须在 IE 中工作)
最佳答案
这应该有帮助。看 fiddle :http://jsfiddle.net/pcDbX/
$('#link').click(function () {
window.open('http://www.example.com','mywindow','width=400,height=200')
});
此链接还将向您展示可以使用哪些参数: http://www.pageresource.com/jscript/jwinopen.htm
以下是传递给 window.open()
的一些常见属性:
width=300 Use this to define the width of the new window.
height=200 Use this to define the height of the new window.
resizable=yes or no Use this to control whether or not you want the user to be able to resize the window.
scrollbars=yes or no This lets you decide whether or not to have scrollbars on the window.
toolbar=yes or no Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).
location=yes or no Whether or not you wish to show the location box with the current url (The place to type the address).
directories=yes or no Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...).
status=yes or no Whether or not to show the window status bar at the bottom of the window.
menubar=yes or no Whether or not to show the menus at the top of the window (File, Edit, etc...).
copyhistory=yes or no Whether or not to copy the old browser window's history list to the new window.
关于jquery - 如何使用 jQuery UI 对话框单击打开一个新的浏览器窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14879585/