Forum Moderators: open
I'm completely new to css,.. yes another one....
I'm trying to make a menu that links to an iframe on the same page. To make it look nicer I added a the following:
onclick="style.backgroundColor='#CCCCCC'; iframe1.location='page1.html'; onmouseover = null ; onmouseout = null; "
onmouseover=" style.cursor='hand'; style.color='#FFFFFF'; style.backgroundColor='#FFCC33' ; return true;"
onmouseout="style.backgroundColor='#FFCC33'; style.color=''; return true;"
when the links is clicked the backgroundcolor stays changed. But with several of these links on this page, I need the first link one back to normal when a second one is clicked.
Is there a solution?
Thanks
<html>
<table style="border-collapse: collapse" bordercolor="#111111" width="160" align="left">
<tr><td width="150" bgcolor="#FFCC33"
onclick="style.backgroundColor='#a90a08'; iframe1.location='page1.html'; onmouseover = null ; onmouseout = null;"
onmouseover="style.backgroundColor='#000066'; style.cursor='hand'; style.color='#FFFFFF'; return true;"
onmouseout="style.background='#FFCC33';style.color=''; return true;" align="center"><strong><font face="Arial, Helvetica, sans-serif" size="1">Link 1</font></strong></td>
</tr>
<tr><td width="150" bgcolor="#FFCC33"
onclick="style.backgroundColor='#a90a08'; iframe1.location='page2.html'; onmouseover = null ; onmouseout = null;"
onmouseover="style.backgroundColor='#000066'; style.cursor='hand'; style.color='#FFFFFF'; return true;"
onmouseout="style.background='#FFCC33';style.color=''; return true;" align="center"><strong><font face="Arial, Helvetica, sans-serif" size="1">Link 2</font></strong></td>
</tr>
<tr><td width="150" bgcolor="#FFCC33"
onclick="style.backgroundColor='#a90a08'; iframe1.location='page3.html'; onmouseover = null ; onmouseout = null;"
onmouseover="style.backgroundColor='#000066'; style.cursor='hand'; style.color='#FFFFFF'; return true;"
onmouseout="style.background='#FFCC33';style.color=''; return true;" align="center"><strong><font face="Arial, Helvetica, sans-serif" size="1">Link 3</font></strong></td>
</tr></table></td>
<iframe src="page0.html" name="iframe1" frameborder="no" marginwidth="10" marginheight="10" style="border:solid black 2px" height="500" width="600">
</iframe></td>
</html>
The onLoad would be (in Pseudocode):
parentFrame.document.getElementById(theLink).style.backgoundColor = The colour you want.
And the onUnLoad would be something similar. I've a feeling that this will mess up the 'pure' CSS events though for the mouseover and mouseout...
#page1 #link1, #page2 #link2, #page3 #link3 {
color: #ffffff;
background: #a90a08;
font-weight: normal;
text-decoration: none;
font-family: Verdana, arial, geneva, sans-serif;
font-size: 10px;
}
Is it possible to "read" the BODY ID of the page loaded in the iFrame?
Here's the complete code
<html>
<style type="text/css">
<!--
#menu a:link, a:visited{
color: #000000;
background: #ffcc33;
font-weight: normal;
text-decoration: none;
font-family: Verdana, arial, geneva, sans-serif;
font-size: 10px;
}
#menu a:hover {
color: #ffffff;
background: #000066;
font-weight: normal;
text-decoration: none;
font-family: Verdana, arial, geneva, sans-serif;
font-size: 10px;
}
#page1 #link1, #page2 #link2, #page3 #link3 {
color: #ffffff;
background: #a90a08;
font-weight: normal;
text-decoration: none;
font-family: Verdana, arial, geneva, sans-serif;
font-size: 10px;
}
-->
</style>
<body>
<div id="menu">
<a href="page1.html" id="link1" target="iframe1">PAGE 1</a>
<a href="page2.html" id="link2" target="iframe1">PAGE 2</a>
<a href="page3.html" id="link3" target="iframe1">PAGE 3</a>
<iframe src="page1.html" name="iframe1" frameborder="no" marginwidth="10" marginheight="10" style="border:solid black 2px" height="500" width="600">
</iframe></td>
</div>
</body>
</html>
Personally I'd suggest the CSS route per message 10, and de-frame the page.
But if you really want to go the framed route, what I'd suggest is define a local variable to keep track of which button is in the pressed state (or you could get that by checking what the iframe's location.href is). Then whenever a button is pressed, you do the following:
Shawn