Welcome to Dream.In.Code
Become an Expert!

Join 149,512 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,360 people online right now. Registration is fast and FREE... Join Now!




onmouseover with href BEHIND

 
Reply to this topicStart new topic

onmouseover with href BEHIND, need table onmouseover and img onmouseout

granaweep
24 Jul, 2007 - 10:18 AM
Post #1

New D.I.C Head
*

Joined: 24 Jul, 2007
Posts: 2


My Contributions
This is what i'm looking for: i want to have a IMG on onmouseout and a table with linked images onmouseover. In firefox i've tried changing the transparency to 0 onmouseover and the pic dissapears but it's still there so it's blocking the links. when i change the z-index or size the img just flashes cause it goes back and forth. I know why it's happening i just dont know how to get around the img to get to my links. In IE the onmouseover doesn't work at all. here's the html:

CODE

<html>

<body>


<head>

<title>Ortonville</title>


<link type="text/css" rel="stylesheet" href="C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/heading.css">
<link type="text/css" rel="stylesheet" href="C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/ortonvillestylesheet.css">
</head>



<div class="headingborder" align=center>
<div align=center>
<img class="logo1" src="C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/CCLogo.gif">

</div>
</div>

<div class="exitborder" align=center>
<div align=center>
<a class="exit1" href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/main.html>Home Page</a>
<a class="exit1" href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/aboutcc.html>About Us</a>
<a class="exit1" href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/notable.html>Notable Jobs</a>
<a class="exit1" href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/crew.html>Meet the Crew</a>
<a class="exit1" href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/contact.html>Contact Us</a>


</div>
</div>


<HR ALIGN=LEFT WIDTH=900>

<p align=center> · HVAC Controls at Ortonville Schools, by Climate Controls </p>


<TABLE class="w850">




<TR valign='top' align=center>
<TD class="header">Ortonville</TD>
</TR>

<TR valign='top' align=center>

<TD>

<TABLE class="w400">

<div id="posrel" class="transOFF" onmouseover="this.className='transON'" onmouseout="this.className='transOFF'">
<img class="wh400" src="C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonmain.JPG">
</div>

<TR valign='top' align=center>


<TD class="wh200">


<a href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonahu1.JPG>
<img class="wh200"src="C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonahu1.JPG"><a/></TD>
</TD>

<TD class="wh200">
<a href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonrtu2.JPG>
<img class="wh200"src="C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonrtu2.JPG"><a/></TD>
</TD>

</TR>

<TR>
<TD class="firstdisc">Ahu1</TD>
<TD class="firstdisc">RTU2</TD>
</TR>






<TR  valign='top' align=center>

<TD class="wh200">
<a href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonunitvent.JPG>
<img class="wh200"src="C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonunitvent.JPG"><a/></TD>
</TD>

<TD class="wh200">
<a href=C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonvavs.JPG>
<img class="wh200"src="C:/Documents and Settings/Dennis Swangler\Desktop/htmljpegs/jobs/ortonville/ortonvavs.JPG"><a/></TD>
</TD>

</TR>


<TR>
<TD class="firstdisc">Unit Vents</TD>
<TD class="firstdisc">VAVs</TD>
</TR>

</TABLE>

<TD>

</TR>
</TABLE>



</body>
</html>






HERE IS THE ORTONVILLESTYLESHEET.CSS:

CODE

p{
text-align:center;
font-weight:bold;
font-size:20px;
width:900px;
margin-left:auto;
margin-right:auto;
}




table{
border-collapse:collapse;
}


#posrel{
position: relative;
}

.w400{
width:400px;

}



.transOFF {}
.transON {
filter:alpha(opacity=0); -moz-opacity: 0;opacity:0;
}



.wh400{
position:absolute;
left:-1px;
top:-1px;
width:415px;
height:455px;

}



.wh200{
width:200px;
height:200px;

}


.firstdisc{
text-align:center;
font-weight:bold;
}



.header{
text-align:center;
font-weight:bold;
font-size:20px;
line-height:80px;
}



AND HERE IS THE HEADING.CSS
CODE

body {

}

.headingborder {
width:900px;
background-color:#7788ff;
margin-left:auto;
margin-right:auto;
align:center;
}

.logo1 {
width:300px;
padding:10px;
}

.exitborder {
padding:25px;
width:900px;
margin-left:auto;
margin-right:auto;
}
.exit1 {
padding:8px;
width:150px;
}



.w850{
width:900px;
margin-left:auto;
margin-right:auto;
}




please help!!!
User is offlineProfile CardPM
+Quote Post

serializer
RE: Onmouseover With Href BEHIND
25 Jul, 2007 - 07:01 AM
Post #2

D.I.C Head
**

Joined: 25 Jun, 2007
Posts: 108


My Contributions
Use visibility:hidden to completely remove an element from the document flow.

I've also noticed something wrong with your links: they reference local files on your hard drive, so won't work when you upload the site. Instead of "C:/Documents and Settings/Dennis Swangler/Desktop/htmljpegs/jobs/ortonville/ortonmain.JPG", you'll need to move the file into the same directory as your html file, and just use href="ortonmain.JPG". Note also that attribute values should be surrounded by double quotes.

--serializer
User is offlineProfile CardPM
+Quote Post

Arbitrator
RE: Onmouseover With Href BEHIND
25 Jul, 2007 - 11:03 AM
Post #3

D.I.C Regular
Group Icon

Joined: 26 Jan, 2005
Posts: 492



Thanked: 1 times
My Contributions
QUOTE(granaweep @ 24 Jul, 2007 - 01:18 PM) *

This is what i'm looking for: i want to have a IMG on onmouseout and a table with linked images onmouseover. In firefox i've tried changing the transparency to 0 onmouseover and the pic dissapears but it's still there so it's blocking the links. when i change the z-index or size the img just flashes cause it goes back and forth. I know why it's happening i just dont know how to get around the img to get to my links. In IE the onmouseover doesn't work at all. here's the html:
I would fix the errors your code. Add a document type declaration [1] (preferably, that of HTML 4.01 Strict), convert presentational elements (including that table) and attributes into CSS, and validate your code [2] [3] to check for errors. If you don’t understand the error messages, you can ask.
  1. http://www.w3.org/QA/2002/04/valid-dtd-list.html
  2. http://www.validome.org/
  3. http://validator.w3.org/

Errors aside, you’ve made it difficult for anyone to help you since your issue involves images and you did not provide these images nor did you specify their dimensions.

QUOTE(serializer @ 25 Jul, 2007 - 10:01 AM) *
Use visibility:hidden to completely remove an element from the document flow.
visibility: hidden doesn’t remove elements from the document flow; elements with that set still take up the space that they would have had the element been visible. display: none, on the other hand, does what you describe.

This post has been edited by Arbitrator: 25 Jul, 2007 - 12:27 PM
User is offlineProfile CardPM
+Quote Post

granaweep
RE: Onmouseover With Href BEHIND
25 Jul, 2007 - 12:21 PM
Post #4

New D.I.C Head
*

Joined: 24 Jul, 2007
Posts: 2


My Contributions
Ok, i know that the links wont work when i upload them, i'm just using this perticular file for testing cause it's faster than opening and saving to the FTP server. the site is up and for now i have just taken out the code for the onmouseover. all pics and pages that i want to do this to are under the "notable jobs" link at the main site. www.climatecontrolinc.net. I have also tried display:none, it halfway works in IE but in firefox it just flashes and the img is left about 100px more than it should be. is absolute placement different in firefox?

Arbitrator. ty for suggestions i will work on 1, 2 and 3 when done putting code back into ortonville

ortonville is up and rdy. right now i have
CODE
display:none
in for the div.transON class

here is the fully edited code i'm using now:
CODE

<html>

<body>


<head>

<title>Ortonville</title>


<link type="text/css" rel="stylesheet" href="http://climatecontrolinc.net/heading.css">
<link type="text/css" rel="stylesheet" href="http://climatecontrolinc.net/ortonvillestylesheet.css">
</head>



<div class="headingborder">
<div align=center>
<img class="logo1" src="http://climatecontrolinc.net/CCLogo.gif">

</div>
</div>

<div class="exitborder">
<div align=center>
<TABLE class="exittable">
<TR>
<TD>
<a class="exit1" href=http://climatecontrolinc.net/index.html>Home Page</a>
</TD>
<TD>
<a class="exit1" href=http://climatecontrolinc.net/aboutcc.html>About Us</a>
</TD>
<TD>
<a class="currat" href=http://climatecontrolinc.net/notable.html>Notable Jobs</a>
</TD>
<TD>
<a class="exit1" href=http://climatecontrolinc.net/crew.html>Meet the Crew</a>
</TD>
<TD>
<a class="exit1" href=http://climatecontrolinc.net/contact.html>Contact Us</a>
</TD>
</TR>
</TABLE>


</div>
</div>

<HR>


<p> &middot HVAC Controls at Ortonville Schools, by Climate Controls </p>


<TABLE class="w850">

<TR valign='top' align=center>
<TD class="header">Ortonville</TD>
</TR>

<TR valign='top' align=center>

<TD>

<TABLE class="w400">

<div id="posrel">
<img class="wh400" onmouseover="this.className='wh400omo'" onmouseout="this.className='wh400omo'" src="http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonmain.JPG">
</div>

<TR valign='top' align=center>


<TD class="wh200">


<a href=http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonahu1.JPG>
<img class="wh200"src="http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonahu1.JPG"><a/></TD>
</TD>

<TD class="wh200">
<a href=http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonrtu2.JPG>
<img class="wh200"src="http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonrtu2.JPG"><a/></TD>
</TD>

</TR>

<TR>
<TD class="firstdisc">AHU1</TD>
<TD class="firstdisc">RTU2</TD>
</TR>






<TR  valign='top' align=center>

<TD class="wh200">
<a href=http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonunitvent.JPG>
<img class="wh200"src="http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonunitvent.JPG"><a/></TD>
</TD>

<TD class="wh200">
<a href=http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonvavs.JPG>
<img class="wh200"src="http://climatecontrolinc.net/htmljpegs/jobs/ortonville/ortonvavs.JPG"><a/></TD>
</TD>

</TR>


<TR>
<TD class="firstdisc">Unit Vents</TD>
<TD class="firstdisc">VAV's</TD>
</TR>

</TABLE>

<TD>

</TR>
</TABLE>



</body>
</html>


the ortonville.css:

CODE

p{
text-align:center;
font-weight:bold;
font-size:20px;
width:900px;
margin-left:auto;
margin-right:auto;
}

.logo2 {
width:200px;
padding:5px;
}

table{
border-collapse:collapse;
}

.w100 {
width:100%;
height:400px;

}

#posrel{
position: relative;
}

.w400{
width:400px;

}







.wh400{
position:absolute;
left:-1px;
top:-1px;
width:415px;
height:455px;
display:inline;
}


.wh400omo{
position:absolute;
left:-1px;
top:-1px;
width:415px;
height:455px;
display:none;
}

.wh200{
width:200px;
height:200px;

}


.firstdisc{
text-align:center;
font-weight:bold;
}



.header{
text-align:center;
font-weight:bold;
font-size:20px;
line-height:80px;
}



and the heading.css:

CODE

body {
text-align: center;
padding:0px;
margin:0px;


}

a img {border: none; }

.plaintxt{
font-size:15px;
font-weight:none;
text-align:left;
}


.headingborder {
width: 100%;
min-width: 900px;
width: expression(document.body.clientWidth < 900? "900px": "auto");
height:250px;
background-image:url(http://www.climatecontrolinc.net/gradimg.jpg);
background-repeat:repeat-x;
margin-left:auto;
margin-right:auto;
}

.logo1 {
display:inline;
width:300px;
margin-bottom:50px;
margin-top:20px;
}

.logo2 {
width:200px;
height:100px;
margin-top:130px;
}


.indiv{
display:inline;
}


.tac{
display:block;
width:200px;
height:240px;
}

a.tac:hover{
display:block;
width:200px;
height:240px;
background-image:url(http://www.climatecontrolinc.net/gradimgop.jpg);
background-repeat:repeat-x;
}

.novus{
display:block;
width:200px;
height:240px;
}

a.novus:hover{
display:block;
width:200px;
height:240px;
background-image:url(http://www.climatecontrolinc.net/gradimgop.jpg);
background-repeat:repeat-x;
}




.exitborder {
padding:0px;
width:900px;
margin-left:auto;
margin-right:auto;
}


.exit1{
display:block;
color:black;
padding:0px;
width:150px;
text-align:center;
text-decoration:none;
border:1px solid black;
background-color:#7FABFD;

}




a.exit1:hover{
display:block;
color:white;
padding:0px;
width:150px;
text-align:center;
text-decoration:none;
border:1px solid #7FABFD;
background-color:#0347C3;
}


.currat{
display:block;
color:white;
padding:0px;
width:150px;
text-align:center;
text-decoration:none;
border:1px solid #7FABFD;
background-color:#0347C3;
}






.w850{
width:900px;
margin-left:auto;
margin-right:auto;
}

#posrel{
position: relative;
}


This post has been edited by granaweep: 25 Jul, 2007 - 07:53 PM
User is offlineProfile CardPM
+Quote Post

Arbitrator
RE: Onmouseover With Href BEHIND
26 Jul, 2007 - 07:34 AM
Post #5

D.I.C Regular
Group Icon

Joined: 26 Jan, 2005
Posts: 492



Thanked: 1 times
My Contributions
QUOTE(granaweep @ 25 Jul, 2007 - 03:21 PM) *
ortonville is up and rdy. right now i have
CODE
display:none
in for the div.transON class
One problem with your current approach is that you want the image removed from flow when you move the mouse over it. As soon as the image is removed, the mouse is no longer positioned over it, so the image reappears. This would create an infinite loop where the image is both disappearing and reappearing until the mouse moves away from the image.

One approach that would work is to have the event listener listen for an event on the container element of the image (you already have this in your initial code) and apply the class attribute to the img element instead of the container.

Your code will probably need more revision than that though since I suspect that it will fail when CSS, JavaScript/ECMAScript, or images are disabled. See http://www.jsgp.us/demos/DIC30807.html for an example of a script that degrades gracefully when the CSS, JavaScript/ECMAScript, or images are missing from the picture.

QUOTE(granaweep @ 25 Jul, 2007 - 03:21 PM) *
is absolute placement different in firefox?
Yes. Several aspects of absolute positioning are handled incorrectly by Internet Explorer. It’s a bit better in Internet Explorer 7, but, I believe, there are still bugs.
User is offlineProfile CardPM
+Quote Post

serializer
RE: Onmouseover With Href BEHIND
26 Jul, 2007 - 07:56 AM
Post #6

D.I.C Head
**

Joined: 25 Jun, 2007
Posts: 108


My Contributions
One major problem is that your <div id="posrel"> is positioned directly after a <table> tag. This is invalid - elements in a table must be within a <td> or <th> to make sense. You've positioned it in a kind of no-man's-land, in between the beginning of the table and the first row; since this position is undefined, browsers tend to do wacky things with it.

I'd also add that id="posrel" is a bad choice for assigning a css rule. You'd be better using a class like "container" to set a position:relative style. What if you want other position:relative objects on your page? You're only allowed to assign an ID once in any given page. For that particular element, an ID of "topsJobs" or something along those lines would make sense. An ID should describe what an element is, rather than what style is being applied to it. This is part of the principal of separating content from presentation, and the semantic nature of markup.

@Arbitrator: Thanks for pointing out my mistake! Pretty stupid of me. Also, the demo page you linked uses some nice techniques, thanks for that also.

--serializer

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:40PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month