我想使用 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/