如何将< script>加载到iframe中? [英] how can i load <script>'s into an iframe?

查看:107
本文介绍了如何将< script>加载到iframe中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的逻辑工作是从父母那里追加到我的iframe

I've got the logic working to append into my iframe from the parent

这个有效:

$('#iframe').load(function() {
  $(this).contents().find('#target').append('this text has been inserted into the iframe by jquery');    
});

这不是

$('#iframe').load(function() {
  $(this).contents().find('body').append('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>');    
});

.lf

问题与插入的脚本标记没有正确转义有关。
一半的javascript在html中变得可见,就像第一个脚本标签突然结束一样。

推荐答案

也许错误与您的字符串有关,永远不会在javascript中创建一个字符串< / script>

Maybe the error is with your string, never create a string in javascript with a literal < /script> in it.

$('#iframe').load(function() {
  $(this).contents().find('body').append('<scr' + 'ipt type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></scr' + 'ipt>');    
});

这篇关于如何将&lt; script&gt;加载到iframe中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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