How to get iframe src page title and then set main page title
+1
A:
Unless the webpage is in the iframe is from the same domain as the containing page, it is impossible.
If they do have the same domain, then try the following:
document.title = document.getElementById("iframe").documentElement.title;
Marius
2009-10-15 07:35:57
`contentDocument`. Except in IE6-7, where you have to fall back to the non-standard `contentWindow.document`. `documentElement` is the root html tag; the `title` property is on the HTMLDocument itself.
bobince
2009-10-15 09:22:32
A:
Granting that iframes src and the parent document src are the same domain:
Parent document:
<html>
<head><title>Parent</title>
<body>
<iframe id="f" src="someurl.html"></iframe>
<script>
//if the parent should set the title, here it is
document.title = document.getElementById('f').contentWindow.document.title;
</script>
</body>
</html>
someurl.html:
<html>
<head><title>Child</title>
<body>
<script>
//if the child wants to set the parent title, here it is
parent.document.title = document.title;
//or top.document.title = document.title;
</script>
</body>
</html>
jerjer
2009-10-15 07:40:18
A:
In case you anyway want to do it using jquery, you can do it as following:
var title = $( "#frame_id").contents( ).find( "title").html( );
$( document).find( "title").html( title);
And pay attention as stated above, you can do it only when script running and page in the same domain, otherwise it's useless.
Artem Barger
2009-10-15 07:56:38