473,773 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE only show the first line after set innerHTML.

I have develop a on-line dictionary website, http://www.stardict.org
I meet a problem:
Here is two lines of js codes:
document.getEle mentById("wordl ist").innerHTM L = "";
document.getEle mentById("defin ition").innerHT ML = "line1<br>line2 ";
The corresponding html codes are:
<table width="100%">
<tr>
<td width="25%" valign="top"><d iv id="wordlist" width="100%" style='
overflow-y:auto; height:352px;'> </div></td>
<td width="8" bgcolor="#88888 8"></td>
<td width="75%" valign="top"><d iv id="definition " width="100%" style='
overflow-y:auto; height:352px;'> </div></td>
</tr>
</table>
But I will find only the first line1 is showed, you can't see line2. By
alert(document. getElementById( "definition").i nnerHTML) you can find the
content is right. If comment the first line which set wordlist's
innerHTML, the result will be shown correctly.
This problem only happen in IE. It is correct in firefox.
Any one can help me to fix the problem? Thanks!

Oct 3 '06 #1
1 2198

hu********@gmai l.com napisal(a):
I have develop a on-line dictionary website, http://www.stardict.org
I meet a problem:
Here is two lines of js codes:
document.getEle mentById("wordl ist").innerHTM L = "";
document.getEle mentById("defin ition").innerHT ML = "line1<br>line2 ";
The corresponding html codes are:
<table width="100%">
<tr>
<td width="25%" valign="top"><d iv id="wordlist" width="100%" style='
overflow-y:auto; height:352px;'> </div></td>
<td width="8" bgcolor="#88888 8"></td>
<td width="75%" valign="top"><d iv id="definition " width="100%" style='
overflow-y:auto; height:352px;'> </div></td>
</tr>
</table>
But I will find only the first line1 is showed, you can't see line2. By
alert(document. getElementById( "definition").i nnerHTML) you can find the
content is right. If comment the first line which set wordlist's
innerHTML, the result will be shown correctly.
This problem only happen in IE. It is correct in firefox.
Any one can help me to fix the problem? Thanks!
I have testes followin example on FF/IE 6 and it works, maybe it will
help ;-):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=windows-1250">
<meta name="generator " content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<script type="text/javascript">
// a counter used to create unique IDs
var Utils = new Object();
Utils.addEvent_ guid = 1;

/**
* Rejestruje funkcje obslugi wybranego zdarzenia dla wskazanego
elementu DOM.
* TODO: zrobic anonynomous function execution...w której bedzie
wybór metody,
* np. wpierw preferowac DOM'a czyli [elem].addEventListen er();
*
* @param element referencja do elementu DOM (tworzona/uzywana
* jest wlasciwosc events tego elementu(typu Object), która
zawiera
* strukture
"nazwa_zdarzeni a"->[lista_funkcji_o bslugi_zdarzeni a(Object)]
*
* @param type nazwa zdarzenia np. click
* @param handler referencja do funkcji obslugi zdarzenia
(przypisywana jest mu
* wlasciwosc $$guid, która jest unikalnym numerem
(wzgledem wszystkich
* funckji obslugi zdarzen))
*/
Utils.addEvent = function(elemen t, type, handler)
{
// assign each event handler a unique ID
// , but what about concurency, (thread races etc. ?), we assume here
// that script is running always in ONE thead...(so it is fine below).
// This is sury true for IE, where event object is a property of
global
// object window (window.event), so for this to work the events must
be
// fired in sequence...
if (!handler.$$gui d) handler.$$guid = Utils.addEvent_ guid++;
// create a hash table of event types for the element
if (!element.event s) element.events = new Object();
// create a hash table of event handlers for each element/event pair
var handlers = element.events[type];
if (!handlers) {
handlers = element.events[type] = new Object();
// store the existing event handler (if there is one)
if (element["on" + type]) {
handlers[0] = element["on" + type];
}
}
// store the event handler in the hash table
handlers[handler.$$guid] = handler;
// assign a global event handler to do all the work
element["on" + type] = Utils.handleEve nt;
};

/**
* Usuwa zarejestrowana funkcje obslugi zdarzenia.
*/
Utils.removeEve nt = function(elemen t, type, handler)
{
// delete the event handler from the hash table
if (element.events && element.events[type]) {
delete element.events[type][handler.$$guid];
}
};

/**
*
*/
Utils.fixEvent_ preventDefault = function()
{
this.returnValu e = false;
};

/**
*
*/
Utils.fixEvent_ stopPropagation = function()
{
this.cancelBubb le = true;
};

/**
* "Poprawia" obiekt event w przegladarkach IE (window.event)
*/
Utils.fixEvent = function(event)
{
// add W3C standard event methods for browsers that do not supports
them(IE)
event.preventDe fault = Utils.fixEvent_ preventDefault;
event.stopPropa gation = Utils.fixEvent_ stopPropagation ;
return event;
};

/**
* Jest wolana, gdy nalezy obsluzyc zdarzenie danego typu (jej
funkcja to
* wolanie wlasciwej funckji obslugi zdarzenia zarejestrowanej
poprzez
* Utils.addEvent( )).
*/
Utils.handleEve nt = function(event)
{
var returnValue = true;
// grab the event object (IE uses a global event object)
event = event || Utils.fixEvent( window.event);
// get a reference to the hash table of event handlers
var handlers = this.events[event.type];
// execute each event handler
for (var i in handlers) {
this.$$handleEv ent = handlers[i];
if (this.$$handleE vent(event) === false) {
returnValue = false;
}
}
return returnValue;
};

/**
* @return szerokosc elementu wraz z padding i border (IE)
*/
Utils.getElemen tWithId = function() {
var getElementWithI d = function() {};

if(document.get ElementById) {
getElementWithI d = function(id) {
return document.getEle mentById(id);
};
} else if(document.all ) {
getElementWithI d = function(id) {
return document.all[id];
};
} else if(document.lay ers) {
getElementWithI d = function(id) {
return document[id];
}
}
return getElementWithI d;
}();
Utils.addEvent( window, 'load', function() {
alert('ok');
Utils.getElemen tWithId("wordli st").innerHTM L = "";
Utils.getElemen tWithId("defini tion").innerHTM L = "line1<br>line2 ";
});

</script>

<table>
<tr>
<td><div id="wordlist" width="100%"></div></td>
<td bgcolor="#88888 8"></td>
<td valign="top"><d iv id="definition" ></div></td>
</tr
</table
</body>
</html>

Greets
Luke Matuszewski

Oct 4 '06 #2

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

Similar topics

1
12641
by: Roger Godefroy | last post by:
Hi There, I would like to show details in another (hidden) TR. It should look like something like on an image I have found wich illustrates it exactly is I want: http://otn.oracle.com/tech/blaf/specs/hide_show/hide_show_VIEWdetails_white1.gif Is there a sample code to do this? I allready could change the status from a hidden tr using:
13
4165
by: kaeli | last post by:
Can anyone explain this to me? It's driving me insane. Save this and run it in IE or Opera and then in Mozilla or Netscape 6+. In IE/Opera, I get the expected 4 alerts. In Mozilla/Netscape, I get *9*. In the example table, there are 4 rows with 4 columns each in the tbody. I'd expect 4 child nodes for the table body with 4 children each. I get those 4 plus 5 alerts in Mozilla/Netscape. I get only those 4 in IE and Opera. Note that...
2
1661
by: John Doe | last post by:
I have a webpage which shows and hides divs as a method of navigation. It works great in the ever evil IE. It works not so great (read not at all) in any standards compliant browser. I haven't ever bothered with standards compliance type stuff before, but am slowly converting. For now I just want to get things working on standards compliant browsers, later I'll actually go fully standards compliant for my web pages. Could someone give me...
1
2018
by: Mel | last post by:
i use the following to add a line. how can i delete the last line ? oDiv = document.getElementById("MyDiv"); oDiv.innerHTML = oDiv.innerHTML + string;
2
13318
by: Eero Tuomenoksa | last post by:
Hi Does someone knows how i can show/hide multible divs at one click? -- Käytössä Operan vallankumouksellinen sähköpostiohjelma: http://www.opera.com/mail/
3
2884
by: Just D. | last post by:
All, What's the simplest way to show my own HTML string on the ASPX page assuming that this page is just created using the wizard and it has nothing on it? We're free to use any control adding it to this page just to show this HTML string. I know that in some cases we can use .InnerHtml property of some controls to inject the HTML string created in C# code, but it didn't work in my case. I tried to use TEXTAREA1.InnerHtml and it shows me...
1
1560
by: preet | last post by:
On first execution of StartSurf() the siteloc returns undefined On second excution and after that there is no problem. StartSurf is called from a button press, which becomes invisible for 30 seconds and then visible again. Suggest solution. The code I am using is
12
8693
by: Rahaman sharif | last post by:
Hi All, I have some problem in innerHtml. I have the textbox in innerHtml, In the innerHtml textbox was read only. I want make it to enable. if user enter the text that text will be retrieved, so i want to be enable text box. Another one problem is the the innerhtml will be in like popup window. it will automatically closed.i want be whenever i click close button that time only it will close. Please help me. here is the Code <html> ...
0
10106
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...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
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...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
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
6717
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
5355
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...
1
4012
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
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.