Solved

Help with code clean up

Posted on 2006-11-29
4
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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