Reputation: 61
I have a frameset with two child frames.
<frameset rows="241px,*" id="header_fr">
<frame src="frame1.htm"/>
<frame src="frame2.htm"/>
</frameset>
I use frame1.htm
just as a header and I change its size dynamically every time content is changed in frame2.htm
.
I change the size of frame1.htm
using parent.document.getElementsByTagName("frameset")[0].rows = new_size + ",*";
Everything is working fine, but sometimes parent.document.getElementsByTagName("frameset")[0]
is no longer available, it's null or not an object. What can be the reason for this problem?
Upvotes: 1
Views: 83
Reputation: 12999
How do you use the JavaScript function? It might be the DOM hasn't loaded completely that caused the issue. You should ensure that the function is executed after the object being fully loaded.
I use the code like below to test and it works well in IE 8, you could check it:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<frameset rows="241px,*" id="header_fr">
<frame src="frame1.htm" />
<frame src="frame2.htm" />
</frameset>
</html>
frame1.htm
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body style="background-color:aquamarine">
111
</body>
</html>
frame2.htm
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body style="background-color:burlywood">
222
<script>
parent.document.getElementsByTagName("frameset")[0].rows = 40 + ",*";
</script>
</body>
</html>
Upvotes: 1