Solved

Help with code clean up

Posted on 2006-11-29
4
190 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now