problem on netscape 7.0 with javascript

W

WL Yang

Hi all,

I am green in javascripts, and facing one problem during waiting web
page. I want to display an image dynamitically in the page and use the
sentences below.

..............
..............
<script language="javascript">
if (document.layers) {
document.write("<img src='" + pics[0] + "' border=1 width=760
height=600 name='displayPic'>");
} else {
showPic(thePic,theSize);
}
........................
................

and it call this function;

function showPic(whichPic,whichSize) {
theSize = whichSize;
if (whichSize == "small") {
var content = "<img src='"+picsS[whichPic]+"' border=1
name='displayPic'>";
}
else {
var content = "<img src='"+picsL[whichPic]+"' border=1
width=760 height=600 name='displayPic'>";
}
}
if (isIE) {
document.all("picDiv").innerHTML = content;
}
if (isNS6) {
document.getElementById("picDiv").innerHTML = content;
}
showPicTime(whichPic);
}

I found that the same image will show twice ( they lies upward and
downward ) on the page when using netscape 7.0 but it will not when
using netscape 7.2 or IE.

am I writing some wrong inside the scripts? or the statement really
display it twice?

thks in advance.

wlyang
 
K

kaeli

Hi all,

I am green in javascripts,

Want some constructive advice then?
Stop doing browser detection.
<script language="javascript">

The language attribute is deprecated in favor of the type attribute. If you
have to support old browsers, it doesn't hurt to use both.
if (document.layers) {
document.write("<img src='" + pics[0] + "' border=1 width=760
height=600 name='displayPic'>");

Are you sure that's what you want?
I'm not sure where in the page this script is running, but usually one sees
document.layers["layername"].document.write("some string");
for NN4.
function showPic(whichPic,whichSize) {
theSize = whichSize;
if (whichSize == "small") {
var content = "<img src='"+picsS[whichPic]+"' border=1
name='displayPic'>";
}

This really isn't the best way to make new pics.
Let me know if you are curious about alternatives using createElement or new
Image().
else {
var content = "<img src='"+picsL[whichPic]+"' border=1
width=760 height=600 name='displayPic'>";
}
}
if (isIE) {
document.all("picDiv").innerHTML = content;

I don't know what isIE is, but Opera also supports document.all.
This is better:

if (document.all && !document.getElementById)
document.all("picDiv").innerHTML = content;
}
if (isNS6) {
document.getElementById("picDiv").innerHTML = content;

I don't know what isNS6 is, but this is better:
if (!document.all && document.getElementById)
document.getElementById("picDiv").innerHTML = content;
}
showPicTime(whichPic);

What is this function doing? Hard to trace problems without all the code.
}

I found that the same image will show twice ( they lies upward and
downward ) on the page when using netscape 7.0 but it will not when
using netscape 7.2 or IE.

7.0 is buggy. I've had numerous problems with it.
I'd need to see a full testable page to play with to say any more about that.
Got a URL with a full test example?

My guess: it's appending instead of replacing. But I dunno for sure.

--
--
~kaeli~
The man who fell into an upholstery machine is fully
recovered.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
W

WL Yang

kaeli said:
Hi all,

I am green in javascripts,

Want some constructive advice then?
Stop doing browser detection.
<script language="javascript">

The language attribute is deprecated in favor of the type attribute. If you
have to support old browsers, it doesn't hurt to use both.
if (document.layers) {
document.write("<img src='" + pics[0] + "' border=1 width=760
height=600 name='displayPic'>");

Are you sure that's what you want?
I'm not sure where in the page this script is running, but usually one sees
document.layers["layername"].document.write("some string");
for NN4.
function showPic(whichPic,whichSize) {
theSize = whichSize;
if (whichSize == "small") {
var content = "<img src='"+picsS[whichPic]+"' border=1
name='displayPic'>";
}

This really isn't the best way to make new pics.
Let me know if you are curious about alternatives using createElement or new
Image().
else {
var content = "<img src='"+picsL[whichPic]+"' border=1
width=760 height=600 name='displayPic'>";
}
}
if (isIE) {
document.all("picDiv").innerHTML = content;

I don't know what isIE is, but Opera also supports document.all.
This is better:

if (document.all && !document.getElementById)
document.all("picDiv").innerHTML = content;
}
if (isNS6) {
document.getElementById("picDiv").innerHTML = content;

I don't know what isNS6 is, but this is better:
if (!document.all && document.getElementById)
document.getElementById("picDiv").innerHTML = content;
}
showPicTime(whichPic);

What is this function doing? Hard to trace problems without all the code.
}

I found that the same image will show twice ( they lies upward and
downward ) on the page when using netscape 7.0 but it will not when
using netscape 7.2 or IE.

7.0 is buggy. I've had numerous problems with it.
I'd need to see a full testable page to play with to say any more about that.
Got a URL with a full test example?

My guess: it's appending instead of replacing. But I dunno for sure.

--


Dears,

thks for yr reply. in facts I got this script from others and really
not know this much. and also thks for telling 7.0 is buggy.^-^

Rgds,
yang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top