Solved

Help with code clean up

Posted on 2006-11-29
4
193 Views
Last Modified: 2010-04-03
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
Comment
Question by:elliottbenzle
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 250 total points
ID: 18039506
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
 
LVL 3

Assisted Solution

by:NIPPLES
NIPPLES earned 250 total points
ID: 18041596
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
 
LVL 4

Author Comment

by:elliottbenzle
ID: 18043776
Thanks guys, that's just what I needed.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 18047813
No problem.  

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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question