Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
136
rated 0 times [  139] [ 3]  / answers: 1 / hits: 29334  / 11 Years ago, fri, january 31, 2014, 12:00:00

This is my code:



<div id=main-content>
<script>
document.title = document.getElementById(main-content-iframe).contentDocument.title;
</script>
<iframe name=cstage src=home.html width=100% height=100% id=main-content-iframe frameborder=0 onload=document.title=parent.frames['cframe'].document.title;>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>


It's not working, what am I doing wrong?


More From » html

 Answers
16

You need to check that the iframe is loaded.



<div id=main-content>
<script src=https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js></script>
<iframe name=cstage src=home.html width=100% height=100% id=main-content-iframe frameborder=0 onload=document.title=parent.frames['cframe'].document.title;>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>
<script>
$( iframe ).on('load',function() {
document.title = document.getElementById(main-content-iframe).contentDocument.title;
});
</script>



[#72822] Thursday, January 30, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alorac

Total Points: 262
Total Questions: 82
Total Answers: 97

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
alorac questions
Sat, Oct 10, 20, 00:00, 4 Years ago
Tue, Sep 22, 20, 00:00, 4 Years ago
Wed, Jul 1, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Sun, May 17, 20, 00:00, 4 Years ago
;