|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I am trying to dynamically change the cell of a table. This works fine in IE. I have an "ID=" on the <td> tag and can use the innerhtml property to change the contents of the cell. In netscape, I tried to use the document.layers['id1'].document.write(), but it doesn't seem to recognize the "id" on the <td> tag. So I tried using the <div> tag which essentially creates another layer. So on the first layer I have an empty cell and on the second layer I have just the <td> and I position it using the top: and left: properties. But this causes problems when resizing. Is there an easier way to do this? Any suggestions would be appreciated. Shelly |
|
#2
|
||||
|
||||
|
<a href="javascript:WriteIt('DIVid',null,'yourtext')"></a>
<script> function WriteIt(id,nestref,text) { if (ns4) { var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document lyr.open() lyr.write(text) lyr.close() } else if (ie4) document.all[id].innerHTML = text } </script> the null - should be used if you have a nested layer - alternatly try a <span id="id>text</span> ------------------ Simon Wheeler FirePages -DHTML/PHP/MySQL |
|
#3
|
|||
|
|||
|
There is a bug in NS when you resize the window. To avoid this problem you have to write this script :
window.onresize = location.reload; This will reload the page after resizing the window. |
|
#4
|
|||
|
|||
|
use data binding
i've replied to a similar question elsewhere - check that one out: http://www.devshed.com/Talk/Forums/...TML/000241.html Ajmal. |
|
#5
|
|||
|
|||
|
Hi Simon,
I tried your javascript and the text doesn't appear on the document. I tried to change the original text and it disappeared. Is there something else i need to do? Thanks in advance, jon <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by firepages: <a href="javascript:WriteIt('DIVid',null,'yourtext')"></a> <script> function WriteIt(id,nestref,text) { if (ns4) { var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document lyr.open() lyr.write(text) lyr.close() } else if (ie4) document.all[id].innerHTML = text } </script> the null - should be used if you have a nested layer - alternatly try a <span id="id>text</span> [/quote] |
|
#6
|
||||
|
||||
|
Hi johnathon, oooops my coding was a bit sloppy wasnt it!, anyway here is a working example, I just tested it to be safe, you do not need to use netscapes <layers> and you should try to avoid them anyway - slap on the wrist for me as I have used if(document.layers) in the script below.
anyway it should give you something to work from. <html> <head> <script> function WriteIt(id,nestref,text) { if (document.layers) { var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document lyr.open() lyr.write(text) lyr.close() } else if(document.all) {document.all[id].innerHTML = text alert("here");} } </script> </head> <body bgcolor="#ffffff"> <div id="thisdiv" style="position:absolute;top:0;left:0;">hello world</div> <a href="javascript:WriteIt('thisdiv',null,'look it actually works.')">testit</a> </body> </html> it is a good idea also to put the text in a table within the div if you want to keep any formatting (for netscape). If the div was nested ie <div id=bella><span id=rosa>text etc</span></div> then you would use <a href="javascript:WriteIt('bella','rosa','look it still works.')">testit</a>. sorry for the confusion ------------------ Simon Wheeler FirePages -DHTML/PHP/MySQL |
|
#7
|
|||
|
|||
|
hello,
Does anyone know how to make this work in a table cell. I used the same thing as above but put the <div> in a table cell, and used relative positioning intead of absolute. When you click 'testit' the new text is not in the table cell !! I tried it with <SPAN> as well and I get the same thing! Any help would be greatly appreciated. Thanks. <html> <head> <script> function WriteIt(id,nestref,text) { if (document.layers) { var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document lyr.open() lyr.write(text) lyr.close() } else if(document.all) {document.all[id].innerHTML = text alert("here");} } </script> </head> <body bgcolor="#ffffff"> <TABLE BORDER=1> <TR><TD> <div id="thisdiv" style="position:relative;">hello world</div> </TD></TR> </TABLE> <a href="javascript:WriteIt('thisdiv',null,'look it actually works.')">testit</a> </body> </html> |
|
#8
|
|||
|
|||
|
I am having exactly the same problem. However, I have noticed that resizing the browser window makes the new table cell contents appear. Maybe there is a function call that would perform the same layer refresh as the browser resize. Any ideas would be appreciated.
|
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > dynamically changing the content of a table cell with Netscape |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|