简体   繁体   English

有没有办法从html页面内阻止外部javascript / bookmarklet执行?

[英]Is there a way to block foreign javascript/bookmarklet execution from within a html page?

For example: Would it be possible to prevent the execution of a bookmarklet with the help of javascript? 例如:是否有可能在javascript的帮助下阻止执行书签?

Background: I'm testing Oracle Siebel with IE8 and since the new version, bookmarklets simply do not work. 背景:我正在使用IE8测试Oracle Siebel,并且由于新版本的存在,书签无法使用。 No feedback, no error. 没有反馈,没有错误。 Verified on multiple clients. 在多个客户端上进行了验证。 If running the code in question via script console, it works. 如果通过脚本控制台运行有问题的代码,它将起作用。

I believe Siebel might be blocking bookmarklets somehow due to security, but how? 我相信Siebel可能出于安全原因以某种方式阻止了书签,但是如何?

It is possible to detect changes in the DOM (see:http://stackoverflow.com/questions/3219758/detect-changes-in-the-dom). 可以检测DOM中的更改(请参阅:http://stackoverflow.com/questions/3219758/detect-changes-in-the-dom)。

But of course it is not 100% safe and there are tools like GreaseMonkey that inject Javascript in pages so basically you can only avoid something for the non-hackers amongst us... :) 但是当然这不是100%安全的,并且有GreaseMonkey之类的工具可以在页面中注入Java脚本,因此基本上,您只能为我们中间的非黑客避免某些事情... :)

Pinterest for instance can not be used on Facebook. 例如,Pinterest不能在Facebook上使用。 If you want to block Pinterest from pinning your side, Pinterest even helps you and does not pin when it sees this in the head section of your page: 如果您想阻止Pinterest固定在您的身边,Pinterest甚至会帮助您,并且在页面的顶部部分显示此内容时也不会固定:

<meta name="pinterest" content="nopin" />

That's not possible. 那不可能 Bookmarklets run in the context of the active website. 书签在活动网站的上下文中运行。 Probably they simply changed something breaking the bookmarklet. 可能他们只是简单地更改了破坏书签的内容。

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

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