473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Java-Script, Icons not showing when loaded

When I open a web page with the following script the "CLfolder.JPG" file
is supposed to show. For some reason I only see the image place holder.
How can I get the CLfolder.JPG to show after the page loads.

<SCRIPT LANGUAGE="JavaScript">
function imgover(imgname){imgname.src = "OPfolder.JPG"}
function imgout(imgname){imgname.src = "CLfolder.JPG"}
</SCRIPT>

<a href="Index.htm" STYLE="text-decoration: none"
onMouseOver="imgover(pic1)" onMouseOut="imgout(pic1)"><font face="MS
Serif" Color="blue">HOME</font></a>

<a href="Contact.htm" STYLE="text-decoration: none"
onMouseOver="imgover(pic2)" onMouseOut="imgout(pic2)"><font face="MS
Serif" Color="blue">contact us</font></a>

-thanks
Mike Solis

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
2 1249
Ivo
"michael solis" wrote
When I open a web page with the following script the "CLfolder.JPG" file
is supposed to show. For some reason I only see the image place holder.
How can I get the CLfolder.JPG to show after the page loads.

<SCRIPT LANGUAGE="JavaScript">
function imgover(imgname){imgname.src = "OPfolder.JPG"}
function imgout(imgname){imgname.src = "CLfolder.JPG"}
</SCRIPT>

<a href="Index.htm" STYLE="text-decoration: none"
onMouseOver="imgover(pic1)" onMouseOut="imgout(pic1)"><font face="MS
Serif" Color="blue">HOME</font></a>

<a href="Contact.htm" STYLE="text-decoration: none"
onMouseOver="imgover(pic2)" onMouseOut="imgout(pic2)"><font face="MS
Serif" Color="blue">contact us</font></a>


You have two variables, pic1 and pic2, that need to correspond to two
images. If the images have something like
id="pic1", then all you need to do is substitute
imgover(pic1)
with
imgover(document.images['pic1'])

HTH
Ivo
Jul 23 '05 #2
michael solis wrote:
When I open a web page with the following script the "CLfolder.JPG" file
is supposed to show. For some reason I only see the image place holder.
How can I get the CLfolder.JPG to show after the page loads.

<SCRIPT LANGUAGE="JavaScript">
function imgover(imgname){imgname.src = "OPfolder.JPG"}
function imgout(imgname){imgname.src = "CLfolder.JPG"}
</SCRIPT>

<a href="Index.htm" STYLE="text-decoration: none"
onMouseOver="imgover(pic1)" onMouseOut="imgout(pic1)"><font face="MS
Serif" Color="blue">HOME</font></a>

<a href="Contact.htm" STYLE="text-decoration: none"
onMouseOver="imgover(pic2)" onMouseOut="imgout(pic2)"><font face="MS
Serif" Color="blue">contact us</font></a>

-thanks
Mike Solis


Why are you mixing CSS and <font> tags on the same page?

<a href="Index.htm"
style="text-decoration: none;font-family:MS Serif;color:Blue;"
onmouseover="return imgover('pic1')"
onmouseout="return imgout('pic1')">HOME</a>

or

<style type="text/css">
a.myLinks {
text-decoration: none;
font-family: "MS Serif";
color: Blue;
}
</style>
....
<a href="Index.htm"
class="myLinks"
onmouseover="return imgover('pic1')"
onmouseout="return imgout('pic1')">HOME</a>

In the same code you provided, I see no tag that resembles:

<img src="..." name="pic1" ...> or <img src="..." name="pic2" ...>

which would be the least that is necessary to make your code function in
Internet Explorer. For a more general solution (give the <img> tags as
defined above) use:

<script type="text/javascript">
function imgover(imgname) {
document.images[imgname].src = "OPfolder.JPG";
return true;
}
function imgout(imgname) {
document.images[imgname].src = "CLfolder.JPG";
return true;
}
</script>

Note that the file names are case-sensitve, and that they will need to
reside in the same directory from which the HTML file containing this
document loaded from in order to work. Also note that your function
indicates it's taking an image _name_, you seem to be passing it an image
reference. The code I've provided resolves this, by passing, and using, an
image name.

Lastly, keep in mind changing the behavior of links confuses users. See
<url: http://www.useit.com/alertbox/9605.html /> item #8. That's from 1996,
but it applies equally today as it did then. Also see <url:
http://www.useit.com/alertbox/20040510.html /> (which is up-to-date, making
the same recommendation not to change link color or behavior).

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Rokamp | last post by:
Hi! I'm testing a russian webpage with HttpUnit, but it seems, that it doesn't support the encoding (Win-1251). How can I add support for this in Java or HttpUnit? ...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
5
by: Thomas G. Marshall | last post by:
This message is sent to these newsgroups because they are no longer valid: comp.lang.java comp.lang.java.api comp.lang.java.bugs comp.lang.java.misc comp.lang.java.setup comp.lang.java.tech ...
1
by: Thomas G. Marshall | last post by:
This message is sent to these newsgroups because they are no longer valid: comp.lang.java comp.lang.java.api comp.lang.java.bugs comp.lang.java.misc comp.lang.java.setup comp.lang.java.tech
0
by: ruhunu Gamarala | last post by:
Hi, I get the following exception periodically. does anybody what is the reason for it to throw this exception? I really appriciate if anyone can help me on this. thanks, Chinthaka at...
0
by: snkssa | last post by:
Hi, I got the following error while building an application with ant. please can you give the solution or reason why it is failing? Thank you create_zip_linux: ...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
7
oll3i
by: oll3i | last post by:
i need to write publisher subscriber application on openjms and use db4o but i dont know how do i add the references to db4o when i compile the app with javac ? i added db4o-6.1-java5.jar to my...
1
by: henrymania | last post by:
Am writing a code for database backup....by backupservlet is as given below i get the following exception
2
by: khalidanwar123 | last post by:
i am getting the following error while updating a clob field. ERROR java.sql.SQLException: Data size bigger than max size forthis type: 4003 19:28:27,499 ERROR at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.