JavaScript doesn't execute in Safari when loading entire page via jQuery's load() method

后端 未结 1 1124
春和景丽
春和景丽 2020-12-21 23:28

I have these two pages:

page1.html

http://vidasp.net/tinydemos/jquery-load-issue/page1.html





        
相关标签:
1条回答
  • 2020-12-21 23:53

    Seems like this is a Safari issue, but maybe not a bug (and may happen in other browsers):

    jQuery uses the browser's .innerHTML property to parse the retrieved document and insert it into the current document. During this process, browsers often filter elements from the document such as <html>, <title>, or <head> elements. As a result, the elements retrieved by .load() may not be exactly the same as if the document were retrieved directly by the browser.

    http://api.jquery.com/load/

    I'm guessing that applies to anytime .load() is used, not just when getting fragments. But I think it would be best, since you are pulling content into a <body> element that it not include a <head> tag?

    0 讨论(0)
提交回复
热议问题