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

need an if then, else then

Status
Not open for further replies.

Javrix

Technical User
Nov 9, 2000
115
US
the website i'm making looks different in netscape and IE. so i need something that will detect a browser and do stuff. example:

if netscape
then <IMG SRC=&quot;line1.jpg&quot;>
else
then <IMG SRC=&quot;line2.jpg&quot;>

something like that. hope this makes sense ~Steve

A broken clock is correct twice per day.

A roomful of monkeys on typwriters will eventually write the great american novel.

If you gave an infinate number of rednecks, an infinate number of shotguns to shoot at an infinate number of street signs, they'd eventually recreate all of Shakespears works in braile.
 
<script>
if(!document.all)
{
document.write(&quot;NS&quot;)
}
else
{
document.write(&quot;IE&quot;);
} luciddream@subdimension.com
 
where do i put the stuff i want it to write? the <IMG SRC=&quot;line1.jpg&quot;> or line2.jpg? ~Steve

A broken clock is correct twice per day.

A roomful of monkeys on typwriters will eventually write the great american novel.

If you gave an infinate number of rednecks, an infinate number of shotguns to shoot at an infinate number of street signs, they'd eventually recreate all of Shakespears works in braile.
 
document.write('<IMG SRC=&quot;line1.jpg&quot;> ') luciddream@subdimension.com
 
Ok, so it's like this:

<script>
if(!document.all)
{
document.write(&quot;NS&quot;)
document.write('<IMG SRC=&quot;line1.jpg&quot;>')
}
else
{
document.write(&quot;IE&quot;);
document.write('<IMG SRC=&quot;line2.jpg&quot;>')
}

</script>

right? ~Steve

A broken clock is correct twice per day.

A roomful of monkeys on typwriters will eventually write the great american novel.

If you gave an infinate number of rednecks, an infinate number of shotguns to shoot at an infinate number of street signs, they'd eventually recreate all of Shakespears works in braile.
 
well, you don't need the document.write(&quot;IE&quot;) or &quot;NS&quot;, i just put that there so you'd know which was which. luciddream@subdimension.com
 
how does it know what to write for each browser then? ~Steve

A broken clock is correct twice per day.

A roomful of monkeys on typwriters will eventually write the great american novel.

If you gave an infinate number of rednecks, an infinate number of shotguns to shoot at an infinate number of street signs, they'd eventually recreate all of Shakespears works in braile.
 
document.write(&quot;something&quot;) actually displays &quot;something&quot; in your page
just like this :
+------------+
| adress bar etc |
+------------+
| |
| something | <----- this is supposed to be the browser window
| |
| |
| |
+------------+

- what we're saying here is that you don't need to display &quot;IE&quot; or &quot;NS&quot; in the client's browser !!
 
I know that, but what I need is the if they're using IE, i need rightline1.jpg to load, if they're using anything but IE, i need rightline2.jpg to load. I did the code from luccidream, and it works, but it's just loading rightline2.jpg. even in IE. here is the code i used:

<SCRIPT>
if(!document.all)
{
document.write('<IMG SRC=&quot;images/rightline1.jpg&quot;>')
}
else
{
document.write('<IMG SRC=&quot;images/rightline2.jpg&quot;>')
}
</SCRIPT>

oh wait, i just switched the two, so rightline2.jpg is on top and rightline1.jpg is on bottom and it worked! thanks guys! ~Steve

A broken clock is correct twice per day.

A roomful of monkeys on typwriters will eventually write the great american novel.

If you gave an infinate number of rednecks, an infinate number of shotguns to shoot at an infinate number of street signs, they'd eventually recreate all of Shakespears works in braile.
 
that was a wonderful graphical representation iza... you should be an artist, not a programmer. luciddream@subdimension.com
 
i was sure you'd love my browser :) (too bad i didn't add some pink & orange & other flashy colors !!!)
(did you notice that this one totally hides the sourc...NO - nobody heard that - did you ?)
 
thanks alot again guys. so i got IE and Netscape 4.0+ working, but netscape 6.0 isn't working. I used the js you guys gave me in 2 different spots. ns 6 working in 1 of them, but doesn't work on the other, any suggestions? ~Steve

A broken clock is correct twice per day.

A roomful of monkeys on typwriters will eventually write the great american novel.

If you gave an infinate number of rednecks, an infinate number of shotguns to shoot at an infinate number of street signs, they'd eventually recreate all of Shakespears works in braile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top