【发布时间】:2014-05-07 13:33:31
【问题描述】:
我有以下代码:
HTML
<p>Click the button to open an about:blank page in a new browser window that is 200px wide and 100px tall.</p>
<button onclick="popitup2()">Open Window</button>
JavaScript
function popitup2() {
newwindow2 = window.open('', 'name', 'height=200,width=150');
var tmp = newwindow2.document;
tmp.write('<html><head><title>popup</title>');
tmp.write('<link rel="stylesheet" href="js.css">');
tmp.write('</head><body><p>this is once again a popup.</p>');
tmp.write('<p><a href="javascript:alert(self.location.href)">view location</a>.</p>');
tmp.write('<p><a href="javascript:self.close()">close</a> the popup.</p>');
tmp.write('</body></html>');
tmp.close();
}
当我在 Firefox 中运行时:弹出窗口的地址栏类似于“http://www.w3schools.com/js/tryit_view.asp?x=0.695266304636076”
当我在 Chrome 中运行相同的程序时:弹出窗口的地址栏类似于“about:blank”
我的问题是:
即使我使用相同的代码 sn-p,为什么两个浏览器却不同? 如何为所有浏览器的弹出窗口制作通用地址栏(url)?
甚至我的应用程序也有这个问题。 我很想知道造成这种情况的根本原因。谁能解释一下?
【问题讨论】:
-
Why it is different for two browsers even though i am using the same code snippet?欢迎来到网络开发。 -
哈哈哈哈,终于找到像我这么讽刺的人了! :D @杰克:D
标签: javascript jquery html google-chrome window.open