Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape and IE 4 equivalents of the following

Status
Not open for further replies.

wickyd

Technical User
Joined
Feb 14, 2002
Messages
57
Location
ZA
Hi everyone

I am new to the developing scene and I need some help with following:

can someone please give me the Netscape 4 and IE 4 equivalents of the following (or at least show me where I can find the answers online):

document.getElementById(id).width
document.getElementById(id).height
document.getElementById(id).offsetWidth
document.getElementById(id).offsetHeigth
document.getElementById(id).offsetTop
document.getElementById(id).offsetLeft
document.getElementById(id).style.posTop
document.getElementById(id).style.posLeft
document.getElementById(id).style.visibility
document.getElementById(id).innerText
document.getElementById(id).innerHTML
document.getElementById(id).style.fontsize
document.getElementById(id).style.letterSpacing

Thank you.
 
I don't think there ARE equivalents for most of those in the browser versions you mention. I'm absolutely certain there aren't equivalents for ones like innerText and innerHTML. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
In pre-Gecko Netscape, there's a supplement for not having
Code:
innerHTML
:
Each
Code:
LAYER
has a
Code:
document
object.
This is just like the normal
Code:
document
object that you begin with.
You have methods like
Code:
write()
and
Code:
close()
.

Like this:
Code:
document.layers.myLayer.document.write('<html></html>');
document.layers.myLayer.document.close();
Layers, however, are not capable of resizing on their own (and they normally don't have scrollbars).
If the content grows larger than it was when the layer originated, then you have to resize it manually:
Code:
document.layers.myLayer.resizeTo(document.layers.myLayer.document.width,
document.layers.myLayer.document.height);
Then, if you have content that is below the layer that should appear as if it were directly below the layer (As in, when the layer resizes, it moves along with the layer), the content below must be in a layer of its own so you can move it up and down -- which you must also do manually:
Code:
document.layers.myLayer2.top=document.layers.myLayer.document.height;
Or, if the moving layer is joined by the side:
Code:
document.layers.myLayer2.left=document.layers.myLayer.document.width;
The above is assuming that
Code:
myLayer
is at the coordinates 0,0 in the layer it is nested inside.
Code:
document.height
and
Code:
document.width
access the document's dimentions -- much like DOM1's
Code:
document.body.scrollHeight
and
Code:
document.body.scrollWidth
.
It is how much the document actually takes, not how much space is allocated for it.



Far less convenient than simply having
Code:
innerHTML
on a non-absolutely-positioned DIV, but at least you can still alter your contents in Netscape :-\.


You can access a layer's visibility like this:
Code:
document.layers.myLayer.visibility


A note about DOM1-accepting browsers:
One convenient thing in normal CSS is that you have the
Code:
display
attribute -- little known, but very nice (except that pre-Gecko Netscape has no equivalent. In pre-Gecko NS, you can set a div's style to display:none, but you can't access it using JavaScript). It acts much like
Code:
visibility
, but if the object is being hidden, it also takes up no space on the page:
IE:
Code:
document.all.myDiv.style.display=&quot;block&quot;;
document.all.myDiv.style.display=&quot;inline&quot;;
document.all.myDiv.style.display=&quot;none&quot;;
DOM1:
Code:
document.getElementById('myDiv').style.display=&quot;block&quot;;
document.getElementById('myDiv').style.display=&quot;inline&quot;;
document.getElementById('myDiv').style.display=&quot;none&quot;;
In case you didn't know, an example of a block is a
Code:
DIV
; it takes up the entire screen from left to right. An example of inline is the
Code:
span
, which sits in the page just like normal text. An example of none is when you put some whitespace on your page ;-). When you tell your object to display none, it will take up absolutely no space on the page. Unless the object you're trying to manipulate is absolutely positioned, this property is quite useful.


Ah yes... You cannot alter the contents of an
Code:
ILAYER
, as it will cause the rest of the page to disappear because of bugs in Netscape that were never fixed.


And another thing, if you have images within layers, you must access them through the layer:
Code:
document.layers.myLayer.document.images
Rather than simply accessing the images through the main
Code:
document
object.


A note, Mozilla (NS 6) does not support the
Code:
innerText
property. It does, however, support
Code:
innerHTML




That's just about all of the things that you would really want to know about DHTML coding for Netscape.
Click here if you want a nice big list of the (very few) properties and methods that pre-Gecko Netscape allows with its objects:





Real friends let friends drive as minors. Will you be my friend?
 
Ah yes... I forgot to tell you where to get the reference for IE's scripting. Go here:
It's best viewed in IE (of course). It may take a while to load, but it has a nice interface (the site) and really helps you along in your quest for more knowledge. (Yes, you're human. That means that yes, you do need visual stimulation in order to navigate and learn best)


... Bah... I think I'll dump that quote about driving as minor.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top