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

Clear document upon opening

Status
Not open for further replies.

xsw1971

Programmer
Jun 21, 2001
153
US
My website is incompatible with Netscape. I have a script that detects if a user opens one of the pages in IE or Netscape. If it's IE they are allowed to continue (the page will open.) If it's Netscape, they are given a choice to click OK (this takes them to a site to download IE) or Cancel (this returns them to the previous page.)

Although Netscape users do not get the chance to "open" the document, they can see all the contents of the page behind the confirm box.

Is there a way to "clear" the document contents, or just make it all white so the user never sees the page contents?

Thanks,
JennieM
 

maybe something like...


if (navigator.appName=='Netscape') {document.write("");}

this should effectively clear the document. i can't test this out since my notepad.exe isn't working, and i have no access on this old comp. to a text editor...

but should work.


- spewn

 
You could do something to this effect. My syntax is way way off but the idea should work.

if navigator - document.location.href=blank.html

Placing this somewhere in the head tag should work. Then you could have the javascript for the confirm box in blank.html.
 
I tried both ways and neither works. Spewn, your way makes the confirm box pop up over and over when I click on Cancel. Nathana, your way didn't do anything at all. maybe I'm not putting it in the right place in my code? Code is below) The code works, I just don't want the page to open under the confirm box for Netscape users to see. Any ideas?

function redirect()
{
if (navigator.appName == "Netscape")
{
[I was putting your code here...]
var netscape = "blah blah blah"; //variable b/c the text
// is long
if (confirm(netscape))
location.href = "URL for IE download...";
else
history.back();
}
}
 
THAT IS SO MEAN!!! If they're using NS, telling them to get IE! That's just uncalled for. What if they're running an OS that IE wasn't made for?

But anyway, if you really want it, put your script in the <head>. The script will then be called before any of the body renders.

And if I were faced with a confirm box like that, I'd close the download site and never return.
bluebrain.gif
blueuniment.gif
 
okay...how about this...

**
<script>

function redirect()

{

if (navigator.appName == &quot;Netscape&quot;)

{

var netscape = &quot;would you like to go to ebay?&quot;;

document.write()
if (confirm(netscape))
location.href = &quot;
}

else {history.back();}

}

</script>

<body onload=redirect()>
here is text you wouldn't see if this was netscape
</body>
**

better, yes?


- spewn
 
Just do this:

<script>
<!--
if(navigator.appName==&quot;Netscape&quot;)
if(confirm('Would you like to get Galeon?')) {
location=&quot; }
else
location=&quot;// -->
</script>
<body>
THIS IS SOME STUPID TEXT THAT YOU WANT TO HIDE FROM THE POOR, INNOCENT NETSCAPE USERS UNTIL THEY CLICK CANCEL.
</body>


This would keep the page from rendering while the confirm box is up there. If they click Okay, they go to Galeon's site. If they click cancel, they go to Mozilla! ;-) You can get rid of that
Code:
else
statement if you actually want the page to render when they click cancel.

And I still think that would be the mean.
bluebrain.gif
blueuniment.gif
 
Spewn, your way still makes the confirm box pop up over and over, and the document is still there behind it. Uniment, my script file IS in the <HEAD> but the document still loads. Not sure what else to try...

JennieM

BTW, this is an intranet site and the company doesn't even support NS. It was a business decision to force IE...
 
i don't get it...i run the following through ie and i get the confirm. if i say yes, go to ebay, i go to ebay. if i cancel, they screen is just blank. no box keeps popping up. please explain. i changed the == &quot;netscape&quot; or != &quot;netscape&quot; to test in ie...

**
<script>

function redirect()

{

if (navigator.appName != &quot;Netscape&quot;)

{

var netscape = &quot;would you like to go to ebay?&quot;;

document.write()
if (confirm(netscape))
location.href = &quot;
}

else {history.back();}

}

redirect();

</script>

**

explain?


- spewn
 
FINALLY!! I think the problem was that I had onload=&quot;redirect()&quot; in the body tag. When I moved it within the script tags it worked!! Thanks for staying on this one, spewn!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top