javascript - Firefox:使用未知域的相对路径的 html 弹出窗口不起作用

标签 javascript firefox

我想使用 javascript:open 函数从图像/图标打开弹出窗口。

使用完全限定的域效果很好。相关页面(目标页面和源页面)是由 servlet 动态生成的。示例:

<img src="../images/report_32.png" alt="test" onclick="javascript:open('http://localhost:80/my-servlet/reports/LOAN', 'LOAN', 'height=600,width=800,resizable=no')">

但是,我想使用相对链接打开弹出窗口,而不知道 servlet 部署到的具体主页。以下示例在 Firexfox (60.0.2) 中工作,但在 Chrome (67.0.3396.87) 和 Edge (42.17134.1.0) 中工作:

<img src="../images/report_32.png" alt="test" onclick="javascript:open('../reports/LOAN', 'LOAN', 'height=600,width=800,resizable=no')">

有谁知道我怎样才能让它在 Firefox 上工作?

最佳答案

更改此:

 onclick="javascript:open('../reports/LOAN', 'LOAN', 'height=600,width=800,resizable=no')"

对此:

 onclick="javascript:window.open('../reports/LOAN', 'LOAN', 'height=600,width=800,resizable=no')"

关于javascript - Firefox:使用未知域的相对路径的 html 弹出窗口不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50853924/

相关文章:

javascript - 数组按第一个字符搜索

javascript - jQuery : focusout of non-required textarea prevent trigger click event of save button

javascript - jQuery:防止用户手指触摸元素时页面滚动

javascript - 在 .on() 点击事件中附加后选择器不起作用

javascript - 如何使用 D3JS 创建带有网格线的 SVG

css - 位置 : sticky support removed from Firefox 31. 0?

python - Selenium - 在新选项卡而不是新窗口中打开 Firefox 链接? Python

css - 在 Firefox 和 IE9+ 上溢出

firefox - Firefox 18打破了mootools 1.2.5选择器引擎

javascript - 返回 promise 与返回 promise 中的未定义之间的区别