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!

can browser detector trigger a popup?

Status
Not open for further replies.

jhdesign

Programmer
Feb 2, 2002
6
US
Hi--I am hoping someone can help me with a script to generate a popup window if the browser sniffer detects a non-CSS-compliant browser. I've tried the ALA solution of hiding a message from compliant browsers suggesting the user upgrade, but I'm looking for a better solution for this site--one that will warn the level-4-browser user from the splash page that they're about to see, heh, a really ugly page when they enter. All the solutions I seem to find call for the user to click on a link or button; I'd like this window to be generated automatically, without the user's needing to click anything, IF the browser is old.

Thanks for any guidance you can give me!

janet
 
how about if the version of the browser being used is less than 4.0, pop the window up...you could even do a conditional one inside the first test to see what version of netscape, if any, they are using...since netscape doesn't support all css, or vice versa...

**
if (parseInt(navigator.appVersion) < 4) {

window open function here;

or add

if (navigator.appName=='Netscape') {add sub functions here}

}
**

i'm sure there is a way to detect if the browser accepts css, maybe in the css forum may be an answer...

-spewn
 
here's a cool way to detect the browsers. IE supports an object called document.all. netscape doesnt, but it has another object called document.layers that IE doesnt support. if u know such an object, u can easily detect the browser or version like this:

if(document.all) //for detecting IE
{...}
else if(document.layers) {...} //for netscape

the code inside if() will b true if that object is supported by the browser. for example, the document.image object (image tag) was not supported bfore version 3 or 4. so using that will detect old browsers. this is called object detection and its much better than the navigator object.

u can also try the plugin object which can detect plugin like flash. i think there's a mime type &quot;text/css&quot; which might help.

luv
Karthik.
 

&quot;here's a cool way to detect the browsers ...&quot; -- only two of them.
Your info is out-of-date for a few years, if not more.

What about Mozilla/Netscape6 and Opera? They don't support not [tt]document.all[/tt], nor [tt]document.layers[/tt]. But they support [tt]document.getElementById[/tt], and this is the way of proper browser abilities detection.
Besides, what about browsers for other OS, like Konqueror for Linux or iCab for Mac?
The world is full of colors, it's not black/white.

According your question, jhdesign, I can tell this: &quot;level-4 browsers&quot; support CSS1 (more or less), and for me personally it's not a reason for cutting them off.

good luck
 
Thanks for your help, everyone.

starway: I do have a detector for Mozilla/NS6 and Opera; I just can't seem to get a script to trigger a popup when the browser doesn't do CSS. (Netscape 4.7 is the one I tend to test with.) However, all browsers will display the site contents--just not the CSS design. I don't think anyone is cut off from the site.

Anyway, if you have any ideas about how to get a popup to work, let me know. The site in its current form (browser detector but no window) is at . The message under the &quot;Enter&quot; is what I'd like to place in a popup window instead.

Thanks--
Janet
 
jhdesign,

I don't really understand what's the problem with pop-up page. In case you don't know how to do it here's the code:[tt]

if (browserversion < 5) {
a = window.open(&quot;&quot;,&quot;warning&quot;,&quot;toolbar=no,width=400,height=250,top=100,left=100&quot;);
a.document.open();
a.document.write(&quot;Please note: This site has been ...&quot;);
a.document.close();
}
[/tt]
But I don't think that pop-up is the best solution. If I were you I'd do the following:
if the browser is &quot;old&quot; (i.e. browserversion<5) the first page displays the info &quot;Please note: ...&quot; as you have now. If the browser is &quot;new&quot; (i.e. browserversion>4), the page automatically redirects to another opening page using document.location.href=url.

Another thing: your index page contains big image in the center with logo and text.
You can essentially reduce total page &quot;weight&quot; in kb, if you convert it to GIF format, or if you split the logo (as image, converted to GIF) and text (as html using CSS).

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top