I have this iframe code:
Yes, just add target="_parent"
on the link and it load on main page.
What you're looking for is <a href="..." target="_parent">
_parent
will cause it to go to the parent frame
_top
will cause it to go to the top-most level.
Either _parent
or _top
should work for your target.
Yes, you can use target="_parent" to achieve this.
"target="_parent" opens the linked document in the parent frame."
Example:
<a target="_parent" href="http://example.org">Click me!</a>
Edit:
If that's not working, you can try _top
:
<a target="_top" href="http://example.org">Click me!</a>
Or base target
:
<base target="_parent" />
Or window.top.location
in JavaScript:
window.top.location = "http://example.com";
You can use javascript to add the target to the links dynamically, something like this.
function onLoadIF(frame)
{
var elements = frame.getElementsByTagName('a'),
len = elements.length;
while( len-- ) {
elements[len].target = "_parent";
}
}
And then add onload="onLoadIF(this)" to the iframe.
If site opens in iframe then redirect to main site
<script>
if (window.top.location != window.self.location) {
top.window.location.href = window.self.location;
}
</script>