HighDots Forums  

Re: innerHTML IE issues

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: innerHTML IE issues in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Randy Webb
 
Posts: n/a

Default Re: innerHTML IE issues - 04-03-2005 , 11:46 PM






mboso wrote:
Quote:
I have a function that works in firefox, but is having some issues in
IE. What it does is place an image in a specified cell, when an icon in
the adjacent cell is clicked.
No, what it does is change the innerHTML of a specified cell. It is far
more efficient (and cross-browser) to simply change the source of the image.

Quote:
I have to click the link half a dozen times for the full size image
to load in the adjacent cell. It appears to load %20 of the image then
stops. In firefox, I click once and it works. any ideas?
Give your image a name attribute, change its .src property via the
document.images collection.

Quote:
Here is the offending code, and well at the HTML. I don't know if it
matters, but I put all my javascript functions in a separate file.

function changeContent(id,shtml) {
if (document.getElementById || document.all) {
var repl = document.getElementById? document.getElementById(id):
document.all[id];
if (repl && typeof repl.innerHTML != "undefined") repl.innerHTML
= shtml;
}
}
var s1='<img src="images/large/scan0001_c.jpg">'
var s2='<img src="images/large/scan0002_c.jpg">'
var s3='<img src="images/large/scan0003_c.jpg">'
var s4='<img src="images/large/scan0004_c.jpg">'
var s5='<img src="images/large/scan0005_c.jpg">'
var s6='<img src="images/large/scan0006_c.jpg">'
var imageList = new Array()
imageList[1]='scan0001_c.jpg';
imageList[2]='scan0002_c.jpg';
imageList[3]='scan0003_c.jpg';
imageList[4]='scan0004_c.jpg';
imageList[5]='scan0005_c.jpg';
imageList[6]='scan0006_c.jpg';

var path = 'images/large/';

function changeImage(newImage){
if (document.images){
document.images['myImage'].src = path + imageList[newImage];
}
}

And then have your html as such:

<img src="something.jpg" name="myImage".....>

And then your links look something like this:

<a href="noJS.html"
onclick="changeImage('');return false">
Change the Image</a>



--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.