ExtJs 模板内的 Javascript 未在 Safari 中执行
我正在尝试执行一些动态附加到 DOM 中的简单 JavaScript。以下代码在 Mozilla Firefox 中有效,但在 Safari 中无效。
Ext.onReady(function () {
var demoHtml = "<span>This is a test</span><script type='text/javascript'>alert('dynamic js works!')</script>";
var demoTpl = Ext.DomHelper.createTemplate(demoHtml);
demoTpl.compile();
demoTpl.append('divRightPane');
});
关于如何解决这个问题有什么想法吗?
谢谢
I am trying to execute some simple javascript that is appended dynamically into the DOM. The following code works in Mozilla Firefox but not in Safari.
Ext.onReady(function () {
var demoHtml = "<span>This is a test</span><script type='text/javascript'>alert('dynamic js works!')</script>";
var demoTpl = Ext.DomHelper.createTemplate(demoHtml);
demoTpl.compile();
demoTpl.append('divRightPane');
});
Any ideas on how to fix this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这与这个问题有关: Safari 和 Chrome 不会评估动态添加的
I think that it's related to this question: Safari and Chrome doesn't evaluate dynamically added <script> tag at page load
I believe that ExtJS template uses DOM functions. In Safari (try Chrome) it will not work.
It seems that document.write should work with scripts, but it's not ExtJS template.
Why do you need to add to the DOM the script inline?
Couldn't you load the script dynamically with eval?