Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts

    Redirecting if IE?

    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:
    Code:
    <!--[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?

  • #2
    New Coder
    Join Date
    Aug 2009
    Location
    Cochin,India
    Posts
    39
    Thanks
    2
    Thanked 1 Time in 1 Post
    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>

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts
    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.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,471
    Thanks
    6
    Thanked 980 Times in 953 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by VIPStephan View Post
    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

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

  • #6
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,274
    Thanks
    28
    Thanked 271 Times in 265 Posts
    Quote Originally Posted by kaitco View Post
    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.

    Code:
    <!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.)
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #7
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts
    For some reason, all the non-IE browsers are showing a duplicate of the iframes. Here is the code I have used:

    Code:
    <!--[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?

  • #8
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,274
    Thanks
    28
    Thanked 271 Times in 265 Posts
    Quote Originally Posted by kaitco View Post
    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.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • Users who have thanked Arbitrator for this post:

    kaitco (11-01-2010)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •