jQuery加载脚本标签 [英] Jquery load with script tags

查看:104
本文介绍了jQuery加载脚本标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一些有关jQuery中.load函数的信息.有没有办法在加载的页面中插入脚本标签?

I read something about the .load function in jQuery. Is there a way to insert the script tags in the loaded page?

当我尝试加载页面时,脚本未加载:s,我想解决此问题.而且getscript()不能选择.

When I try to load a page the scripts doesn't load :s, I want to fix this. And getscript() isn't a option.

推荐答案

.load()返回包含<script>标签的HTML内容时,jQuery会剥离<script>标签,将其移动, 1 执行它们,然后将其删除.

When .load() returns HTML content that contains <script> tags, jQuery strips out the <script> tags, moves them,1 executes them, and then removes them.

尽管这使调试器难以逐步执行这些脚本,但脚本 do 执行.

While this makes it hard to step through those scripts with a debugger, the scripts do execute.

  • http://www.bennadel.com/blog/1605-jQuery-AJAX-Strips-Script-Tags-And-Inserts-Them-After-Parent-Most-Elements.htm
  • http://forum.jquery.com/topic/using-load-with-script-tags-doesn-t-work

1 要么是<head>,要么是最父元素—.尽管我可以检查jQuery的源代码,但是我还没有找到权威的源代码.

1Either to the <head>, or the parentmost element — I haven't found an authoritative source on this yet, though I could just check the jQuery source...

这篇关于jQuery加载脚本标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆