简体   繁体   English

如何使用JavaScript打开新的浏览器窗口?

[英]How to open new browser window using javascript?

I need to open new browser window using java script window.open, i have html page but it getting error as page not found.This is from jsf/icefaces.I have display the html page directly.Please help me... 我需要使用Java脚本window.open打开新的浏览器窗口,我有html页面,但找不到页面时出现错误。这来自jsf / icefaces。我直接显示了html页面。请帮助我...

    JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(),
"window.open('printerFriendly.html','Print',,'width=300','height=200','menubar=yes',
'status=yes','location=yes','toolbar=yes','scrollbars=yes')");

Try something like this: 尝试这样的事情:

<FORM>
<INPUT type="button" value="New Window!" onClick="window.open('http://stackoverflow.com','mywindow','width=400,height=200,toolbar=yes,
location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,
resizable=yes')">
</FORM> 

It's in a form, but the JS code would be the same for any other link. 它是一种形式,但是JS代码对于其他任何链接都是相同的。

Opening a New Window With JavaScript 使用JavaScript打开新窗口

http://www.pageresource.com/jscript/jwinopen.htm http://www.pageresource.com/jscript/jwinopen.htm

Javascript (JS) Tutorial - opening new browser window using open ... Javascript(JS)教程-使用open打开新的浏览器窗口...

http://www.hscripts.com/tutorials/javascript/open-method.php http://www.hscripts.com/tutorials/javascript/open-method.php

window.open opens new browser window. window.open打开新的浏览器窗口。 If you getting page not found error, may be you should check that the page exists? 如果发现页面未找到错误,可能是您应该检查页面是否存在?

您的JavaScript是正确的,您需要更正URL('printerFriendly.html')。

Page Not Found is Page Not Found. 找不到页面是找不到页面。 Check if the URL is correct. 检查URL是否正确。 Is printerFriendly.html located in the same folder as your current page? printerFriendly.html是否与当前页面位于同一文件夹中? It should be. 它应该是。 Or you should provide the correct path. 否则,您应该提供正确的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM