开发者

<script> in $.html() $.load() what is the spec?

开发者 https://www.devze.com 2023-02-23 06:44 出处:网络
jQuery does not seem to document how it behaves when using $.html() or $.load() to insert an HTML document fragment into the current DOM:

jQuery does not seem to document how it behaves when using $.html() or $.load() to insert an HTML document fragment into the current DOM:

What does it do with < script > tags?

They are executed, though. But are nowhere to be found in the DOM. It seems jQuery inserts the开发者_如何学C script blocks just for a moment into the DOM or evals it.

There is no documentation this regard. Do you know any way to tune it, i.e. disable it? This has implications of security in nature!


The <script> tags are stripped out of the code and explicitly executed after the DOM has been updated.

If you use "$.load()" with a URL that's got a selector in it (it's a hack-y feature of the API), like this:

$.load("http://something #stuff", ... )

then it will not run the scripts.

0

精彩评论

暂无评论...
验证码 换一张
取 消