...

View Full Version : Redirecting if IE?



kaitco
10-26-2010, 05:35 AM
I have two iframe on a page, but I have found the only way to ensure a transparent background for the iframe in any version of IE is to include the attribute allowTransparency="true".

Since allowTransparency="true" on an iframe does not validate in either HTML 4 or 5, however, I have decided to redirect a page if someone is using any version of IE.

I have used the following code to redirect on any version of IE:

<!--[if IE]>
<meta http-equiv="refresh" content="0;http://xfiles.doriennesmith.com/indexIE.php">
<![endif]-->
The problem is that instead of redirecting to the new page, the page simply refreshes and loads continuously.

Is the above incorrect? Must I use a javascript to complete the redirect?

sujithpr
10-26-2010, 05:56 AM
yes you need to use javascript.
browser information is contained in navigator object. Please try this
<html>
<body>

<script language="JavaScript"
type="text/JavaScript">
if(navigator.appName == "WebTV")
{
alert("You're using the WebTV browser.")
}
if(navigator.appName == "Netscape")
{
alert("You're using a Netscape browser.")
}
if(navigator.appName == "Microsoft Internet Explorer")
{
alert("You're using the Internet Explorer browser.")
}
</script>

</body>
</html>

kaitco
10-26-2010, 05:59 AM
Where do I include the new site where the page will redirect if it is IE?

Also, that code looks like it will add a popup/alert which I really do not want. I just want to seamlessly redirect.

VIPStephan
10-26-2010, 06:07 AM
Oh COME ON!!! Please go away with these crappy browser sniffing scripts that used to be popular in the early 90’s.

kaitco, you could use JS to add the allowtransparency attribute to the iframe dynamically or use conditional comments to serve a different iframe to IE.

kaitco
10-26-2010, 06:35 AM
kaitco, you could use JS to add the allowtransparency attribute to the iframe dynamically or use conditional comments to serve a different iframe to IE.

Any suggestions on a script? I have tried several variations of


<script>
function function1() {
document.all.iframeA.allowTransparency = "true";
document.all.iframeB.allowTransparency = "true";
}
</script>
and the iframe still looks all white in IE.

Arbitrator
10-26-2010, 07:57 AM
I have two iframe on a page, but I have found the only way to ensure a transparent background for the iframe in any version of IE is to include the attribute allowTransparency="true".

Since allowTransparency="true" on an iframe does not validate in either HTML 4 or 5, however, I have decided to redirect a page if someone is using any version of IE.A simpler approach would be to use conditional comments as is shown in the code below.

Note that, in the below code, you will need to substitute the URI http://www.example.edu/ with the URI of a document in the same domain as that hosting the iframe; Internet Explorer apparently forbids changing the background color of an iframed document that isn't in the same domain as the host document. I'd guess that this is for security reasons.


<!doctype html>
<html lang="en-US">
<head>
<meta name="Content-Type" content="text/html; charset=UTF-8">
<title>Demo Document</title>
<style>
* { margin: 0; }
html { background-color: beige; color: black; }
iframe { display: block; margin: 1em auto; }
</style>
</head>
<body>
<!-- This code is for browsers other than Windows Internet Explorer. -->
<!--[if !IE]>-->
<iframe width="500" height="500" src="http://www.example.edu/"></iframe>
<!--<![endif]-->
<!-- This code is for Windows Internet Explorer. -->
<!--[if IE]>
<iframe width="500" height="500" src="http://www.example.edu/" allowtransparency="true"></iframe>
<![endif]-->
</body>
</html>

(The code was tested in Firefox 3.6 and Internet Explorer 9 Beta.)

kaitco
10-26-2010, 09:35 AM
For some reason, all the non-IE browsers are showing a duplicate of the iframes. Here is the code I have used:



<!--[if !IE]>-->
<iframe src="poll/character.php" height="350" width="250"></iframe>
<br />
<iframe src="poll/season.php" height="350" width="250"></iframe>
<br />
<!--<![endif]-->
<!--[if IE]-->
<iframe src="poll/character.php" height="350" width="250" allowtransparency="true"></iframe>
<br />
<iframe src="poll/season.php" height="350" width="250" allowtransparency="true"></iframe>
<br />
<!--[endif]-->

IE shows just the one set of iframes, but FF, Opera, Safari and Chrome all show duplicates. Any thoughts?

Arbitrator
10-26-2010, 11:46 AM
IE shows just the one set of iframes, but FF, Opera, Safari and Chrome all show duplicates. Any thoughts?You didn't copy the conditional comment code correctly.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum