I have these two pages:
page1.html
http://vidasp.net/tinydemos/jquery-load-issue/page1.html
<!DOCTYPE html>
<html>
<body>
<div id="wrap"> </div>
<script src="jquery.js"></script>
<script> $(function() { $('#wrap').load('page2.html'); }); </script>
</body>
</html>
page2.html
http://vidasp.net/tinydemos/jquery-load-issue/page2.html
<!DOCTYPE html>
<html>
<head>
<script> alert('Page 2 HEAD'); </script>
</head>
<body>
<p> PAGE 2 </p>
<script> alert('Page 2 BODY'); </script>
</body>
</html>
As you can see, I am loading the entire page2.html into the #wrap element of page1.html. Notice, that page2.html contains two SCRIPT elements with alert() function calls – one in the HEAD of the page, and the other one in the BODY of the page.
The issue:
In Firefox 3.9, IE9 beta, Chrome (latest) and Opera 11, both alerts execute.
In Safari 5, only the second alert executes.
Is this a Safari bug?
Seems like this is a Safari issue, but maybe not a bug (and may happen in other browsers):
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?