Wednesday, March 5, 2014

How to get title from IFrame document

HTML code:
 
<div id="main-content">   
    <iframe name="cstage" src="home.html" width="100%" height="100%" id="main-content-iframe" frameborder="0">If you're seeing this message, it means IFrames are not supported; Please enable IFrames or upgrade to a compatible browser that supports IFrames.</iframe>
</div> 

jQuery code:
 
alert($('#main-content-iframe').contents().find("title").text());
 
 
Note: Make sure home.html come from the same domain as your main page. 

No comments:

Post a Comment