Reputation: 35485
It seems that adding an iframe to my html document prevents Javascript from being executed. In the following code sample the alert will not be shown:
<html>
<body>
<iframe src="http://www.google.com" />
<script type="text/javascript">
alert("test");
</script>
</body>
</html>
What am I doing wrong?
Upvotes: 1
Views: 217
Reputation: 536349
You're using the ‘self-closing’ XML syntax for <iframe>
in a page that's being parsed as text/html
and not XML (application/xhtml+xml
).
Browsers parsing HTML don't know about this syntax; you have to use <iframe>...</iframe>
. The content between the start and end tag is fallback content for browsers that don't support iframes, but there aren't really so many of those any more. Nevertheless, HTML still requires the end-tag.
Upvotes: 4