Reputation: 10773
I have the following html in a page:
<div>
<iframe src="http://google.co.in" style="width:200px;height:200px">
</iframe>
<iframe src="http://" style="width:200px;height:200px">
</iframe>
</div>
This page displays correctly in Firefox:
But in IE (7 & 8), the whole page gets replaced with the following error page:
Upvotes: 0
Views: 2267
Reputation: 72530
Since the URL is user-defined, you must have a server-side script that is generating that page. So you can easily check for an invalid URL (or at least, a blank one or just http://
) and either not display anything, put the iframe code with no src parameter, or put a default page.
Upvotes: 0
Reputation: 1655
I wouldn't rely on the browser to check the validity of the URL for you if you want consistent behavior across all browsers.
If it's a user-entered url that you need to validate, consider validating it yourself (probably using regular expressions either in the back-end or javascript depending on your app) before loading it into the iframe. That way you can display your own error message on your own terms if they entered an invalid url.
Upvotes: 0
Reputation: 449435
Even though I agree this behaviour is odd, it may be intended for security purposes. Try about:blank
rather than http://
.
Upvotes: 1