Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Help with code clean up

I'm trying to clean up my code where I've gotten a lot of excess stuff using copy paste and deleting the old images from the deisgn view. I have a chunk of code where I'm pretty sure something is reapeating itself. This chunk of code is only supposed to display one rollover image. Can someone tell me what parts I can safely cut out?

<a href="index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/homeon.jpg',1)"></a><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/lghomeon.jpg',1)"><img src="images/lghomeoff.jpg" alt="home" name="home" width="140" height="30" border="0" id="home" /></a>
0
elliottbenzle
Asked:
elliottbenzle
  • 2
2 Solutions
 
Jason C. LevineNo oneCommented:
Hi elliott,

The first <a> tag isn't doing anything.  Remove this:

<a href="index.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/homeon.jpg',1)"></a>

You should be left with:

<a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/lghomeon.jpg',1)"><img src="images/lghomeoff.jpg" alt="home" name="home" width="140" height="30" border="0" id="home" /></a>
0
 
NIPPLESCommented:
Hi there...

you can then safely remove some more stuff if you are using XHTML which i guess you are because the img tag you close staright away without a </image> closing tag.


<a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/lghomeon.jpg',1)"><img src="images/lghomeoff.jpg" alt="home" width="140" height="30" id="home" /></a>

I removed the border attribute (invalid xhtml) and i removed the image name because as far as i know you just need the id in order for it to work with the javascript.  If you really want to cut code but keep it valid you can remove more....

<a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/lghomeon.jpg',1)"><img src="images/lghomeoff.jpg" alt="home" id="home" /></a>

The height and width are optional - images will 'take shape' faster when the browser draws them but i prefer to leave them out and have cleaner & lighter code - up to you.

Finally the javascript can come out too and you can do it in pure CSS.  The Javascript is slower and very dated escpecially the ones that come with Dreamweaver.  Doing that is outside the scope of your question i think but as a preview the html will look as simple as this after the change...

<a href="index.html"><img src="images/lghomeoff.jpg" alt="home" /></a>

Now isnt that easy to look at!!! Any it will work faster too.

Hope this helps.
0
 
elliottbenzleAuthor Commented:
Thanks guys, that's just what I needed.
0
 
Jason C. LevineNo oneCommented:
No problem.  

You've been posting a lot of issues.  How is the site coming along?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now