相关疑难解决方法(0)

Javascript:检测/防止外部脚本

是否可以检测可能通过浏览器加载项,代理,xss等加载到页面中的外部脚本?

说我有这个网页:

<html>
    <head>
        <title>Hello world!</title>
        <script src="http://mydomain.com/script.js"></script>
    </head>
    <body>
        Hello world!
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

是否可以在我的script.js文件中包含一些脚本,以检测页面上的其他脚本元素何时来源http://mydomain.com

我想要的东西可以检测源中包含的其他脚本(即onload事件触发时它们存在)和页面加载后的任何时间添加的脚本.

如果我能检测到这些脚本,我还能以某种方式阻止它们吗?

如果我知道还有其他的事情发生,这对于调试用户报告的javascript/ui问题很有用.

我使用jQuery,所以jQuery的答案对我有用.我只是不想限制jQuery的答案.


编辑

我的解决方案如下.但是,它有两个(潜在的)问题:

  1. 这取决于jQuery.
  2. 它不会检测通过CSS @import规则(或任何带有url()值的规则)加载的外部资源.

如果有人想提交一个解决其中一个或两个问题的答案,我会赞成.

如果你两个都解决了,我会接受你的回答.

html javascript xss load external

6
推荐指数
1
解决办法
4918
查看次数

我在线商店的SF Visual Search是什么东西?

我发现这看起来像我的在线商店的插件,我不知道如何删除它.它只出现在产品详细信息页面中:http://heavenlynature.co.nz/shop/shower/berry-chocolate-dessert-soap

到目前为止,我只发现这个插件出现在Windows 7,Firefox 19上.任何人都可以发光吗?

屏幕截图:http: //francisthedesigner.com/images/bug.jpg

这是它生成的代码

`<div id="SF_VISUAL_SEARCH" style="display: block; z-index: 1990000; position: fixed; -moz-user-select: none; width: 360px; overflow: visible; top: -3325px; left: 1552px; opacity: 100;">
<div id="SF_ScreenLayout" style="opacity: 0.01; z-index: 1989995; width: 100%; height: 100%; position: fixed; left: 0px; top: 0px; display: none; background-color: white;"></div>
<div id="SF_arrSurface" style="position: absolute; z-index: 1989990; opacity: 0.7; left: 0px; top: 0px; display: block; background-color: transparent;">
<sfmsg id="sfMsgId" data="{"imageCount":0,"ip":"1.1.1.1"}"></sfmsg>
<div id="SF_SA_INFO" style="display:none;z-index:1990000;-moz-user-select: none;-khtml-user-select:none;user-select:none;width:324px;height:394px; background: transparent;">
<div id="SF_IIAD_0" style="height: …
Run Code Online (Sandbox Code Playgroud)

html css web

5
推荐指数
2
解决办法
2323
查看次数

标签 统计

html ×2

css ×1

external ×1

javascript ×1

load ×1

web ×1

xss ×1