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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape 4.7 Javascript problem

Status
Not open for further replies.

SamCKayak

Programmer
Jan 16, 2004
3
US
I use the script below to control the maximum-width of a table. It works fine in IE and Netscape 7.1

/* Restrict growth of element on very-wide displays */

function resizeBox(){
sObj = document.getElementById("container")
if ( sObj ) {
if(document.body.clientWidth) (document.body.clientWidth>1024) ? sObj.style.width = "955px" : sObj.style.width = "100%"
}
}

window.onload = resizeBox;
window.onresize = resizeBox;

--------------------------------------

<table id=&quot;container&quot;>


In Netscape 4.7, no error appears, and I belive the JavaScript is running correctly. But it changes the TABLE element's style so the width is held to 1024 pixels.

It's like a no-op in Netscape 4.7.

Is there some other style or element attribute that I should try?

Sam
 
Change:
Code:
if(document.body.clientWidth) (document.body.clientWidth>1024) ? sObj.style.width = &quot;955px&quot; :  sObj.style.width = &quot;100%&quot;
to:
Code:
if (document.body.clientWidth) sObj.style.width =(document.body.clientWidth > 1024) ? &quot;955&quot; : &quot;100%&quot;
and see how that works.
Also check the value of [tt]document.body.clientWidth[/tt] in NS4.7 with:
Code:
window.alert(&quot;client width = &quot; + document.body.clientWidth);
Hope that helps.

[tt]________________________________________________________________
Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
Sorry, missed the [tt]px[/tt] off the [tt]995[/tt] in my alternative code.

[tt]________________________________________________________________
Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top