Reputation: 21066
i'm using following page to display content of a url in a iframe and changing it based on input value .
<html>
<head>
<script type="text/javascript">
function changeUrl()
{
var url=document.getElementById('browseurl').value;
if(url!="")
{
if(url.indexOf("http")==-1)
{
url="http://"+url;
}
document.getElementById('browserWnd').src=url;
}
}
</script>
</head>
<body>
<div >
<span>Url</span>
<input id="browseurl" name="browseurl" type='textbox' />
<input id="browse" type='button' value="changeurl" onclick="changeUrl()" />
</div>
<iframe id="browserWnd" src="http://www.coolmath.com/" height="700" width="625"></iframe>
</div>
</body>
</html>
my problem is browsing some inner pages of an url loaded in iframe changes the parent window url instead of loading in iframe ...
for ex http://www.coolmath.com/ load in iframe but while browsing some links loads the entire page in parent window.
Upvotes: 1
Views: 2573
Reputation: 16210
You may notice that even something like this <iframe src='http://www.coolmath-games.com/0-fraction-splat/index.html'></iframe>
results in the same. This is a technique called frame-busting. It's in their page's code:
<script>
<!-- Hide Script
if (top.location != self.location) {
top.location = self.location
}
//End Hide Script-->
</script>
If you have a server, that can respond with a HTTP/1.1 204 No Content
header, you may be able to "deactivate" this frame buster as described here.
Upvotes: 2
Reputation: 65342
From www.coolmath.com:
if (window.self != window.top) ...
meaning the site activly escapes being framed.
Upvotes: 2