Connecting Tech Pros Worldwide Help | Site Map

problem on netscape 7.0 with javascript

WL Yang
Guest
 
Posts: n/a
#1: Jul 23 '05
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
kaeli
Guest
 
Posts: n/a
#2: Jul 23 '05

re: problem on netscape 7.0 with javascript


In article <ba72998e.0411032236.40ac48f2@posting.google.com >,
atropos@hutchcity.com enlightened us with...[color=blue]
> Hi all,
>
> I am green in javascripts,[/color]

Want some constructive advice then?
Stop doing browser detection.
[color=blue]
> <script language="javascript">[/color]

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.
<script type="text/javascript" language="javascript">
[color=blue]
> if (document.layers) {
> document.write("<img src='" + pics[0] + "' border=1 width=760
> height=600 name='displayPic'>");[/color]

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.
[color=blue]
>
> function showPic(whichPic,whichSize) {
> theSize = whichSize;
> if (whichSize == "small") {
> var content = "<img src='"+picsS[whichPic]+"' border=1
> name='displayPic'>";
> }[/color]

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().
[color=blue]
> else {
> var content = "<img src='"+picsL[whichPic]+"' border=1
> width=760 height=600 name='displayPic'>";
> }
> }
> if (isIE) {
> document.all("picDiv").innerHTML = content;[/color]

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;
[color=blue]
> }
> if (isNS6) {
> document.getElementById("picDiv").innerHTML = content;[/color]

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

What is this function doing? Hard to trace problems without all the code.
[color=blue]
> }
>
> 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.[/color]

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

WL Yang
Guest
 
Posts: n/a
#3: Jul 23 '05

re: problem on netscape 7.0 with javascript


kaeli <tiny_one@NOSPAM.comcast.net> wrote in message news:<MPG.1bf3f0f431b573e998a257@nntp.lucent.com>. ..[color=blue]
> In article <ba72998e.0411032236.40ac48f2@posting.google.com >,
> atropos@hutchcity.com enlightened us with...[color=green]
> > Hi all,
> >
> > I am green in javascripts,[/color]
>
> Want some constructive advice then?
> Stop doing browser detection.
>[color=green]
> > <script language="javascript">[/color]
>
> 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.
> <script type="text/javascript" language="javascript">
>[color=green]
> > if (document.layers) {
> > document.write("<img src='" + pics[0] + "' border=1 width=760
> > height=600 name='displayPic'>");[/color]
>
> 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.
>[color=green]
> >
> > function showPic(whichPic,whichSize) {
> > theSize = whichSize;
> > if (whichSize == "small") {
> > var content = "<img src='"+picsS[whichPic]+"' border=1
> > name='displayPic'>";
> > }[/color]
>
> 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().
>[color=green]
> > else {
> > var content = "<img src='"+picsL[whichPic]+"' border=1
> > width=760 height=600 name='displayPic'>";
> > }
> > }
> > if (isIE) {
> > document.all("picDiv").innerHTML = content;[/color]
>
> 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;
>[color=green]
> > }
> > if (isNS6) {
> > document.getElementById("picDiv").innerHTML = content;[/color]
>
> I don't know what isNS6 is, but this is better:
> if (!document.all && document.getElementById)
> document.getElementById("picDiv").innerHTML = content;
>[color=green]
> > }
> > showPicTime(whichPic);[/color]
>
> What is this function doing? Hard to trace problems without all the code.
>[color=green]
> > }
> >
> > 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.[/color]
>
> 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.
>
> --[/color]


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
Closed Thread