【发布时间】:2016-11-17 12:59:40
【问题描述】:
我有一个显示 2 个按钮和 1 个 iframe 的页面。这 2 个按钮(按钮 A 和 B)控制 iframe 的内容。我创建了一个伪类 (.button:focus),因此用户可以看到 iframe 中当前处于活动状态的内容。
页面以 A 开始。所以我想要的是 .button:focus 在用户加载页面时对按钮 A 处于活动状态。这样一来,iframe 中当前处于活动状态的内容就很清楚了。 我曾考虑在 body 上使用 onload 函数,但无法设置正确的函数。
HTML:
<body>
<div id="load">
<a class="button" href="Test_Hoover_A.html" target="Targetframe">Schets A</a>
</div>
<a class="button" href="Test_Hoover_B.html" target="Targetframe">Schets B</a>
<br>
<br>
<br>
<iframe src="Test_Hoover_A.html" name = "Targetframe" height=700 width=900 style="border:2px solid green;" ></iframe>
</body>
CSS:
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
float: left;
-webkit-transition-duration: 0.4s;
}
.button:focus {
background-color: #3e8e41;
}
.button:hover {
background-color: #555555;
color: white;
【问题讨论】:
标签: javascript button onload pseudo-element