jQuery .load() call doesn't execute JavaScript in loaded HTML file

后端 未结 13 1714
难免孤独
难免孤独 2020-11-22 08:28

This seems to be a problem related to Safari only. I\'ve tried 4 on Mac and 3 on Windows and am still having no luck.

I\'m trying to load an external HTML file and

13条回答
  •  长情又很酷
    2020-11-22 08:38

    You are loading an entire HTML page into your div, including the html, head and body tags. What happens if you do the load and just have the opening script, closing script, and JavaScript code in the HTML that you load?

    Here is the driver page:

    
     
        
            
            jQuery Load of Script
            
            
            
        
        
            
            

    Here is the contents of trackingCode.html:

    
    

    This works for me in Safari 4.

    Update: Added DOCTYPE and html namespace to match the code on my test environment. Tested with Firefox 3.6.13 and example code works.

提交回复
热议问题