Solved

Sliding iframe in IE7

Posted on 2013-01-05
6
567 Views
Last Modified: 2013-01-16
In testing a page in IE7 (using F12 key in IE9), I'm getting this tremendously weird effect where clicking on a link on a page embedded inside an iframe is causing the layout of the parent page to change.  Intuitively, this shouldn't happen, when no JavaScript is involved.

To demonstrate, there are two pages. I have pasted the code for those pages below and also attached the files.  The test case is this:  Place the two files in a directory and use IE to open the main page (e.g., the one containing the iframe).  Make sure that IE is in "IE7" mode.  Then click the link that says "Click test."  This has an href of "#" which should essentially do nothing (or at most, affect the content inside of the iframe).  But instead, it causes the iframe to shift to the left and text outside the iframe ("Testing 1 2 3") to disappear.

I'm wondering if anyone can explain why this happens and offer a simple solution, preferrably CSS-based, that would prevent this from happening without affecting IE8+, Firefox, Chrome, or other recent browser.

The page that loads inside the iframe (which must be called "simple.html") is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Test</title>
	
</head>
<body>

<h1>Test</h1>

<a href="#">Click test</a>

</body>			
</html>			

Open in new window


The outer page is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  dir="ltr" lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Frame Weirdness</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <style type="text/css">

	#region-main-box {
		background: rgb(25, 255, 237); left: 220px; width: 200%; float: left; position: relative;
	}
	#region-post-box {
		background: rgb(254, 25, 237); left: 50%; width: 100%; margin-left: -440px; float: left; position: relative;
	}
	#region-main-wrap {
		background: rgb(254, 255, 23);
		width: 50%; right: 100%; float: right; position: relative;
	}
	#region-pre {
		background: rgb(25, 25, 230);
		left: 220px; width: 220px; overflow: hidden; margin-left: -50%; float: left; position: relative;
	}
	#region-main-pad {
		background: rgb(25, 95, 255);
		margin: 0px 10px 0px 450px; overflow: hidden;
	}	  	
	#region-pre {
		background: rgb(255, 200, 190);
		left: 220px; width: 220px; overflow: hidden; margin-left: -50%; float: left; position: relative;
	}	
	#region-pre .block-region {
		margin: 0px; padding: 0px; width: 220px; float: left;
	}

    
    
    </style>
    
    
    
</head>

<body>


	<div id="region-main-box">
		<div id="region-post-box">
			<div id="region-main-wrap">
				<div id="region-main-pad">	
					<div class="region-content">
						<div class="resourcecontent resourcegeneral">
							<iframe id="resourceobject" src="simple.html"></iframe>
						</div>
					</div>	
				</div>
			</div>
			<div id="region-pre" class="block-region">
			           <div class="region-content">
			                          <div style="background-color: #e1e1e8" id="specialtoc">Testing 1 2 3. Testing 1 2 3.<br /><br /></div>
			           </div>
			</div>
		</div>
	</div>

</body>
</html>

Open in new window

weird.zip
0
Comment
Question by:Newbis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:Newbis
ID: 38748053
PS...I should clarify that if you try it in another browser, the link is hard to see because of the colors used (they were just to make it easier to see the divs); in any case, that doesn't matter because the test case is with IE7.  (Also, I accidentally pasted the region-pre selector twice and gave it two different colors; you can take out the redundant style, as it has no bearing.)
0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 500 total points
ID: 38748701
Basically IE7 is getting confused.  It assume that it should be linking to the current location on the inner page; and no longer is referencing the outer page code.

IE7 was the most defective browser that Microsoft ever delivered, and trying to make it behave is a lost cause.  I doubt there is any fix or workaround for this, and I have not seen any reference to this behavior.  Fortunately almost no one is using IE7. On my site my stats show < 1% of user are on IE7; there are more on IE6.

Cd&
0
 

Author Comment

by:Newbis
ID: 38749128
Well fortunately, I did find a potential fix for it... I can replace # with something that I know isn't in the page such as #nogo.  (There are a number of links that go to "#" and have some JavaScript with the onClick method.)  But I have to do that for every single place and page where it may occur; that's why I was hoping to find some simple CSS hack that I could just put in one place.

By the way, IE7 is the furthest back I can go by pressing F12 in IE9.  The F12 thing is very handy and makes it easy to test a few different options on just one machine.  Is there some simple way to test IE6 other than booting up an old machine with it installed?

(I'm thinking of using spoon.net/browsers, but there's a download, and www.virustotal.com says that software contains Trojan/Refroso.adhx.  Too bad, since that looked like a good option.)
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38749389
I don't know of any IE6 emulation, and testing for obsolete browsers is not something I do.  I consider it a waste of time trying to make old junk work in a modern world.

Cd&
0
 

Accepted Solution

by:
Newbis earned 0 total points
ID: 38760128
I found one... http://www.browserstack.com/  ... cloud-based, and they have a free trial and lots of browsers and OSs, although performance is slow.  So, the issue happens in IE6 too.  Basically it seems to be related to using href="#" by itself.  Very strange, but as I said, putting some random text after the "#" seems to fix it.
0
 

Author Closing Comment

by:Newbis
ID: 38782011
Never got a response that really explains what's causing it, but I found the solution myself, which I've mentioned above.  It affects at least IE6 as well as IE7, and the solution ended up being pretty simple, so I figured it's worth fixing.
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question