Tuesday, September 6, 2011

How to get iframe src page title and then set main page title

To get iframe src page title and then set main page title::

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; 



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.

No comments:

Post a Comment

Popular Posts