Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > need javascript help

need javascript help
Thread Tools
Grizzled Veteran
Join Date: May 2002
Location: Houston, TX
Status: Offline
Reply With Quote
Feb 2, 2004, 11:31 AM
 
Stupid IE on Windows. Seems it is the only browser that does not render .png's with transparency (that I know of. If anyone knows another borwser that does this let me know). So I need to find a javascript that will redirect the user to one page if they are using IE on Win, and another page if they are using any other browser/OS combo. I've found scripts that redirect based on Win/Mac, and I've found scripts that redirect based on IE/Netscape(mozilla), but none that do both. And I'm not nearly a good enough coder to cobble those two together into a working form.

Does anybody know where I can get a script that does this? Or any super coders out there feel like writting one up quick?

Thanks.
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Feb 2, 2004, 12:16 PM
 
There are multiple solutions to this issue. I have seen three approaches that allow png alpha channel on IE. You can google for them, but here is a quick link to one of them:

http://www.daltonlp.com/daltonlp.cgi...mp;item_id=217
     
Grizzled Veteran
Join Date: May 2002
Location: Houston, TX
Status: Offline
Reply With Quote
Feb 2, 2004, 12:29 PM
 
Originally posted by larkost:
There are multiple solutions to this issue. I have seen three approaches that allow png alpha channel on IE. You can google for them, but here is a quick link to one of them:

http://www.daltonlp.com/daltonlp.cgi...mp;item_id=217
Thanks for the quick response.

That's interesting, but not exactly what I'm looking for. I've allready got my pages made, one with PNGs and one with JPGs. The JPEG Win IE page doesn't look quite as good, but it will do. I just need a way to redirect Win IE users to that page instead of the normal one.
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Feb 2, 2004, 12:41 PM
 
This should work:

Code:
<html> <script language="JavaScript"> var agt=navigator.userAgent.toLowerCase(); if ((agt.indexOf("msie") != -1) && (agt.indexOf("windows") != -1)) { //Windows Internet Explorer document.location.href = "index_msiewin.html"; } else { //Everybody else document.location.href = "index_other.html"; } </script> </html>
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Feb 2, 2004, 12:52 PM
 
to arkham_c, I was just about to post virtually the same thing. I would however point out that
Code:
filter: progid: DXImageTransform.Microsoft.AlphaImageLoader
would allow the windows IE users to see the .png... I know - who cares about IE/Win users, but it's nice all the same.

How about something along the lines of what is shown here:

http://forums.macrumors.com/archive/topic/50459-1.html

I was going to write this myself, but I needed to do a google search for the filter thing cos it's quite long, and i tend not to code for IE/win nowadays, so i couldn't remember it all

Anyhoo - I think it'll only work for ie5.5+ users, but it's good enough. Checking for "MSIE 6.0" in the userAgent string and directing them to your alphaImageLoader page, the good guys to your proper png page and the old time MSIE users to your jpeg page wouldn't be too hard...
     
Grizzled Veteran
Join Date: May 2002
Location: Houston, TX
Status: Offline
Reply With Quote
Feb 2, 2004, 01:55 PM
 
Originally posted by Arkham_c:
This should work:

Code:
<html> <script language="JavaScript"> var agt=navigator.userAgent.toLowerCase(); if ((agt.indexOf("msie") != -1) && (agt.indexOf("windows") != -1)) { //Windows Internet Explorer document.location.href = "index_msiewin.html"; } else { //Everybody else document.location.href = "index_other.html"; } </script> </html>
mucho gracias! just what i was looking for!
     
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Feb 2, 2004, 02:01 PM
 
if you already have the images as both .jpg & .png, why not just use the same page? quite easy, really (assuming you have php access). just something like this would do the trick: [php]<?
if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false) {
$ext = "jpg";
} else {
$ext = "png";
}
?>
// check it returns the correct extension
<p>$ext = .<? echo $ext ?></p>
<img src="image.<? echo $ext ?>">[/php] no sense in coding 2 different sets of pages.
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
Feb 2, 2004, 08:44 PM
 
Ooh. philzilla, that's pretty clever. Good idea.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:55 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2