简体   繁体   中英

Javascript inside ExtJs template not executed in Safari

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM