473,795 Members | 2,914 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

innerHTML IE issues

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. 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?

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(i d,shtml) {
if (document.getEl ementById || document.all) {
var repl = document.getEle mentById? document.getEle mentById(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" >'

*************** **********

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<title>Sheila Turner</title>

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<script language="javas cript" type="text/javascript"
src="../../scripts/generate_addres s_script.js"></script>
<link href="../../css/style.css" rel="stylesheet " media="all"
type="text/css" title="Main stylesheet">
</head>

<body>

<div align="center" id="padtable">
<table id="frametable" >
<tr>
<td id="rtd">
Sheila Turner
</td>

<td>
<div id="vericons1"> <a href="javascrip t:;"
onclick="change Content('rtd',s 1)"><img
src="images/small/scan0001_i_sq.j pg"></a></div>
<div id="vericons"> <a href="javascrip t:;"
onclick="change Content('rtd',s 2)"><img
src="images/small/scan0002_i_sq.j pg"></a></div>
<div id="vericons">< a href="javascrip t:;"
onclick="change Content('rtd',s 3)"><img
src="images/small/scan0003_i_sq.j pg"></a></div>
<div id="vericons">< a href="javascrip t:;"
onclick="change Content('rtd',s 4)"><img
src="images/small/scan0004_i_sq.j pg"></a></div>
<div id="vericons">< a href="javascrip t:;"
onclick="change Content('rtd',s 5)"><img
src="images/small/scan0005_i_sq.j pg"></a></div>
<div id="vericons">< a href="javascrip t:;"
onclick="change Content('rtd',s 6)"><img
src="images/small/scan0006_i_sq.j pg"></a></div>
</td>

</tr>
</table>
</div>
</body>
</html>

Jul 23 '05 #1
1 2028
mboso wrote:
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.
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.

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(i d,shtml) {
if (document.getEl ementById || document.all) {
var repl = document.getEle mentById? document.getEle mentById(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.jp g';
imageList[2]='scan0002_c.jp g';
imageList[3]='scan0003_c.jp g';
imageList[4]='scan0004_c.jp g';
imageList[5]='scan0005_c.jp g';
imageList[6]='scan0006_c.jp g';

var path = 'images/large/';

function changeImage(new Image){
if (document.image s){
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="change Image('');retur n false">
Change the Image</a>

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2

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

Similar topics

4
2631
by: Nick | last post by:
OK. I've had a trawl through past messages but can see nothing that helps me, so...here goes... I am writing a web application which, among other things, pushes a web page to a user's browser. In very simple terms: - I have a script in hidden frame A which sets the document.location of main frame B.
24
3515
by: bedhead | last post by:
Why doesn't a SELECT element's innerHTML reflected which option was selected? Works in IE. I need this functionality so that I can retain what choices a user made in a tabbed interface. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://w3.org/1999/xhtml"> <head> <script language="javascript">
63
4806
by: Jake Barnes | last post by:
In the course of my research I stumbled upon this article by Alex Russel and Tim Scarfe: http://www.developer-x.com/content/innerhtml/default.html The case is made that innerHTML should never be used. I'm wondering, If I wanted all the content of BODY as a string, how else could I get except through innerHTML?
4
5133
by: tcole6 | last post by:
My problem appears to be Firefox specific. I have a hyperlink that loads a new window. This window contains hyperlinks that call javascript functions in the parent window and then closes the child window. The function that is called contains an XMLHttpRequest. My problem is that everything happens as it should, the innerHTML is changed by the results of the XMLHttpRequest and the child window closes. The problem is this, in Firefox,...
8
3220
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this javascript is not working. e.g. html content:
2
1586
by: artev | last post by:
for make on-fly some box te3xt and select, (select that will be use for to choose datas) is better to use Dom or innerhtml?
1
4588
by: Tarik Monem | last post by:
I have been able to successfully retrieve data from an xml file, where the data has been massaged a little bit, to create a table to be retrieved and it is displayed via a document.writeln within a javascript file, but now I am going to go completely AJAX & using innerHTML to display the same information to the browser. First, snippets of the original code that was working with no problem: XML first: <title>bla bla</title> ...
6
10770
by: David Gillen | last post by:
Hello, I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is okay. I have within my html <tbody id="dataTable" name="dataTable"></tbody> And then some javascript (using prototype to get the element)
6
6115
omerbutt
by: omerbutt | last post by:
hi there i have a registration page on which i have a captcha verification method i customized that code for the sake that the user is able to refresh the captcha images by staying on the same page via AJAX ,now the code i have written works perfect in IE6 , the user clicks the Refresh button and the new images is populated but when using FIREFOX it is doing nothing, i have placed the Captcha Image inside a div and on getting response(the new...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7544
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6784
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.