x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>蜜蜂教程(mifengjc.com)</title>
6
<script>
7
function changeStyle() {
8
var x = document.getElementById("myframe");
9
var y = (x.contentWindow || x.contentDocument);
10
if (y.document) y = y.document;
11
y.body.style.backgroundColor = "#0000ff";
12
}
13
</script>
14
</head>
15
<body>
16
17
<iframe id="myframe" src="/examples/demo_iframe.htm">
18
<p>你的浏览器不支持iframes。</p>
19
</iframe>
20
<br><br>
21
<input type="button" onclick="changeStyle()" value="修改背景颜色">
22
23
</body>
24
</html>