473,379 Members | 1,542 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,379 software developers and data experts.

Images don't load when using JavaScript in SRC= attribute for FireFox

Hello,

I'm in a quandary as to how to address a problem. The site in question:

http://agapeyoga.com

On the left-hand side of the site are image navigation elements that
change when clicked based on where you are in the navigation heirarchy.
They work just fine in IE, but Firefox doesn't load the initial state
of the images. If you mouse over the images that have onmouseover or
onmouseout events, though, the images associated with those events do
pop up correctly. I have tired a few "best guess" stabs using OnLoad
events to no avail. Grateful for your help. Javascript file is at.

http://agapeyoga.com/common/lib_main.js

sample HTML code:

<a href="../" onMouseOver="imgHov('home');"
onMouseOut="simNav('home');">

<img src="javascript:simNav('home');" name="home" border="0" width="66"
height="20"></a>

The simNav function:

function simNav(n_name) {
var url =this.location.href
var
root_name =url.substring(url.indexOf(n_name),eval(url.indexO f(n_name)+
n_name.length))
if (this.document) {
if (n_name == root_name || (n_name == "home" && homepage ==
"y")) {
document[n_name].src = eval(n_name + "On" + ".src");
} else {
document[n_name].src = eval(n_name + "Off" + ".src");
}
}
return (document[n_name].src);
}

Sample image source loading for javascript:

homeOn = new Image(); // Active images
homeOn.src = "/images/n_home_on.gif";

Very grateful for your help!

Jan 21 '06 #1
3 2078


I don't think using javascript: call as protocol hanndler on an
attribute has been added as standard, so, it seems proprietary so
far, last I looked in HTML4.01 specs, they have reserved for future
works to add it BUT using ="{&yourcodehere}" NOT javascript:, but has
not been added yet on xhtml1 or else yet, thus.

Danny
Jan 22 '06 #2

jb******@gmail.com wrote:
<img src="javascript:simNav('home');"


You have no clue what a javascript: URL is good for, the expression
following the javascript: is supposed to yield the data to load so
unless your simNav('home') call returns image data that the image
element can render that construct is pointless.

See <http://www.elf.org/pnglets/> where that is used in a way it makes
sense.

If you need to call that simNav function then use
<script type="text/javascript">
simNav('home');
</script>
where that function needs to be called.
Use a static image element e.g.
<img src="whatever.gif" alt="whatever" name="whatever">
so that with or without JavaScript the image or its alt text is rendered.
If you only want to render the img element with script then use
document.write
<script type="text/javascript">
document.write(
'<img src="whatever.gif" alt="whatever" name="whatever">');
</script>
of course there you have all the power of JavaScript expressions thus if
you have a function yielding a URL then you can do
<script type="text/javascript">
document.write(
'<img src="' + getURL('whatever') + '" alt="whatever" '>');
</script>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 22 '06 #3
Interesting solution, worth trying, many thanks. Another alternative I
was thinking of was trying to use an "eval" statement around the
"javascript:" statement, since it seems to execute fine enough once the
page is loaded.

Thanks,
John Blossom

Jan 23 '06 #4

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

Similar topics

11
by: Penelope Baker | last post by:
Greetings: I cannot seem to get IE 6.0 to pre-cache my rollover images. Every time the user rolls over a link, it rereads it from the server, even though it is well into the cache by that time....
3
by: src_mag | last post by:
Hello, I'd like to write JavaScript code that refreshes a frame once a second loading a different image each time. Basically, here's what the script would do: 0 sec load img0.gif 1 sec load...
2
by: Trent | last post by:
Hey All, I am new to javascript and currently coding a site with scripts that are beyond my level of understanding. The problematic page has thumbnail images that can be clicked on to zoom in....
10
by: cosmic foo | last post by:
I have a page with about 100 images of about 10k each. where a typical img tag looks like this, <img src="item001.jpg" height="70" alt="" onMouseOver="showPic(this)" border="0"> Not all the...
2
by: mikeoley | last post by:
Ok I have a Javascript slideshow working. Every image is linked to a another page in the site. Problem is...The link wont refresh to the next link once the second images rollovers in the slideshow....
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
3
by: littleark | last post by:
Hi everybody, I have a typical javascript images preloader, it works fine both on Firefox and on IE in my intranet (local server). It works fine on the Internet (remote server) in IE. In...
5
by: rosaryshop | last post by:
I'm working a jewelry/rosary design web site at http://www.rosaryshop.com/rosariesAndKits2.php. As the user makes selections, it updates images of various parts, giving them a preview of the...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.