ask:
There are two frames embedded in a web page, as shown below. Now I want to write a piece of code in b.htm to change the height of the Topbar frame (originally 120). How to achieve this? It is best to write down the specific process.
In addition, if it cannot be achieved, is there any way to use a picture in b.htm across the frame Main to cover a.htm (the purpose is to make a.htm invisible)?
Additional question: a.htm cannot be modified.
Please help me.
================================================== ====
<html>
<head>
<title></title>
</head>
<body>
<frameset rows="120, *">
<frame name="Topbar" src="a.htm" scrolling="No">
<frame name="Main" src="b.htm" scrolling="Yes">
</frameset>
</body>
</html>
================================================== ====
Supplementary question: Thank you ccyingfu, but the frameset of my embedded frame cannot be modified. That is to say, the above code cannot be modified and the ID cannot be added. What should I do? In addition, you used a button to execute the modification. What if I want to execute it as soon as I open the web page?
answer:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<frameset rows="120, *">
<frame name="Topbar" src="a.htm" scrolling="No">
<frame name="Main" src="b.htm" scrolling="Yes">
</frameset><noframes></noframes>
</html>
</html>
================================
b.htm
====================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function change(height){
window.parent.document.getElementsByTagName("frameset")[0].setAttribute("rows",height+"px,*");
}
window.onload = function(){
alert("Original height"+window.parent.document.getElementsByTagName("frameset")[0].getAttribute("rows").substring(0, 3));
change(150);//Set the height of 150 pixels
alert("changed height"+window.parent.document.getElementsByTagName("frameset")[0].getAttribute("rows").substring(0, 3));
}
</script>
</head>
<body>
</body>
</html>
=========
You try this, it's absolutely possible. It also meets your requirement of not changing the frameset. I just added a piece of js code to b.htm to change the height of the frameset when b.html is loaded. It turned out to be 120, but was changed to 150 through js. You can change 150 to a larger value, so that you can see the effect.