href带有“ javaScript”在iframe中没有工作
我有page.html以下代码:
<iframe srcdoc="<a href="javascript:console.log(1)">test</a>" sandbox="allow-same-origin || allow-scripts || allow-top-navigation || allow-popups"></iframe>
我允许脚本,最佳动态和弹出窗口。 当我在浏览器中加载Page.html时(Firefox tastest),我可以在iFrame中看到超链接测试,但是这里是问题:当我单击它时 - 在遵循代码时(F12)中没有出现在Console(F12)中:
<iframe srcdoc="<script>console.log(1)</script>" sandbox="allow-scripts || allow-top-navigation || allow-popups"></iframe>
在控制台中输出“ 1”。 HREF中的JavaScript为什么不工作?
I have page.html where there is following code:
<iframe srcdoc="<a href="javascript:console.log(1)">test</a>" sandbox="allow-same-origin || allow-scripts || allow-top-navigation || allow-popups"></iframe>
I allow scripts, top-navigation and popups.
When I load page.html in browser(Firefox Lastest), I can see hyper-link test in iframe, but here is the problem: when I click it - nothing appears in console(F12) while following code:
<iframe srcdoc="<script>console.log(1)</script>" sandbox="allow-scripts || allow-top-navigation || allow-popups"></iframe>
Outputs "1" in console.
Why wouldn't the javascript in a href work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
javaScript:...
)允许same-origin
:如果不使用此令牌,则将资源视为来自特殊总是失败的相同原始政策的来源。请参阅 mdn docjavascript:...
)allow-same-origin
: If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy. see MDN doc here