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 have the JavaScript that is embedded execute.
The code I'm trying to use is this:
$("#myBtn").click(function() {
$("#myDiv").load("trackingCode.html");
});
trackingCode.html
looks like this (simple now, but will expand once/if I get this working):
<html>
<head>
<title>Tracking HTML File</title>
<script language="javascript" type="text/javascript">
alert("outside the jQuery ready");
$(function() {
alert("inside the jQuery ready");
});
</script>
</head>
<body>
</body>
</html>
I'm seeing both alert messages in IE (6 & 7) and Firefox (2 & 3). However, I am not able to see the messages in Safari (the last browser that I need to be concerned with - project requirements - please no flame wars).
Any thoughts on why Safari is ignoring the JavaScript in the trackingCode.html
file?
Eventually I'd like to be able to pass JavaScript objects to this trackingCode.html
file to be used within the jQuery ready call, but I'd like to make sure this is possible in all browsers before I go down that road.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…