Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with code clean up

Posted on 2006-11-29
4
Medium Priority
?
198 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 1000 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 1000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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