The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Iframe and the browsers back button
nyhetsgrupper
post Jan 17 2010, 02:11 AM
Post #1





Group: Members
Posts: 2
Joined: 17-January 10
Member No.: 10,849



I have this simple html page:
CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <h1>Header</h1>
    <iframe id="myIframe" src="http://www.amazon.com/" style="width:100%; height:500px"/>
</html>


As you can see I load amazon.com into an iframe (but this has nothing to do with amazon.com, it applies for any site). If I click on a link at the web site loaded in the iframe the browser back button gets enabled. If I click the back button I would expect the iframe to go back to the last visited page, and leave my hosting page (the page containing the header and the iframe) untouched. This is also what happens in Chrome, but in IE8 it replaces the complete page with amazon.com (and my header and Iframe is then gone). Is this a bug in IE? Can I get it to behave like I want?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 17 2010, 06:14 AM
Post #2


.
********

Group: WDG Moderators
Posts: 8,238
Joined: 10-August 06
Member No.: 7



I get no back button at all in IE8. unsure.gif

BTW, here's an example of a "minimal" XHTML document: http://www.w3.org/Consortium/Offices/Prese...ns/XHTML/4.html --note the explicit HEAD and BODY elements (the W3C example uses a Strict Doctype which doesn't permit iframes, so you should stick with your transitional Doctype). In HTML4 the HTML, HEAD and BODY element tags are optional (TITLE is mandatory, though).

BTW 2, it seems the end tag for the IFRAME really can be replaced with an ending slash in the start tag, is that valid XHTML (tested in WDG and W3C validators)? unsure.gif


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Jan 17 2010, 07:29 AM
Post #3


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



QUOTE
BTW 2, it seems the end tag for the IFRAME really can be replaced with an ending slash in the start tag, is that valid XHTML (tested in WDG and W3C validators)?


IIUTQC, I think so. All tags must be closed, but you are allowed to replace a content free one like

<MOLLUSC></MOLLUSC>

by (the to me immensely ugly)

<MOLLUSC />

Isn't that it? I might have quite misunderstood the question. Oh, I mean, IMHQMTQ.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 17 2010, 09:20 AM
Post #4


.
********

Group: WDG Moderators
Posts: 8,238
Joined: 10-August 06
Member No.: 7



QUOTE(Brian Chandler @ Jan 17 2010, 01:29 PM) *

QUOTE
BTW 2, it seems the end tag for the IFRAME really can be replaced with an ending slash in the start tag, is that valid XHTML (tested in WDG and W3C validators)?


IIUTQC, I think so. All tags must be closed, but you are allowed to replace a content free one like

<MOLLUSC></MOLLUSC>

by (the to me immensely ugly)

<MOLLUSC />

Isn't that it? I might have quite misunderstood the question.

No, that's what I was asking.

QUOTE
Oh, I mean, IMHQMTQ.

IMHMTQ? wacko.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
nyhetsgrupper
post Jan 17 2010, 02:36 PM
Post #5





Group: Members
Posts: 2
Joined: 17-January 10
Member No.: 10,849



I changed the html a litle, to make it validate:
CODE

    <!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 page</title>

<style type="text/css">
iframe.c1 {width:100%; height:500px}
</style>
</head>
<body>
<div>
<h1>Header</h1>
<iframe id="myIframe" src="http://www.amazon.com/" class="c1" name="myIframe"></iframe></div>
</body>
</html>



The result is exactly the same. When I click on what ever link in the amazon.com page showing in the iframe the browser back button is enabled, and if i press back amazon.com is replacing my page (not showing my header and iframe anymore).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 17 2010, 06:21 PM
Post #6


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,402
Joined: 9-August 06
Member No.: 6



It isn't right to slash it when a closing tag exists. IFRAME isn't empty BTW. That's why it has a closing tag.

The choice between closing tag and slash only exists for real empty elements that have no closing tag in HTML. Adding a closing tag to those isn't compatible with all browsers so that leaves us with the ugly slash anyway.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 17 2010, 08:03 PM
Post #7


.
********

Group: WDG Moderators
Posts: 8,238
Joined: 10-August 06
Member No.: 7



QUOTE(nyhetsgrupper @ Jan 17 2010, 08:36 PM) *

The result is exactly the same. When I click on what ever link in the amazon.com page showing in the iframe the browser back button is enabled, and if i press back amazon.com is replacing my page (not showing my header and iframe anymore).

Seems to be something strange with amazon.com, when I disabled javascript in IE8 I got a functional Back button. Framing other sites works fine even with javascript.

This post has been edited by Christian J: Jan 18 2010, 05:42 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jan 17 2010, 08:07 PM
Post #8


.
********

Group: WDG Moderators
Posts: 8,238
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Jan 18 2010, 12:21 AM) *

It isn't right to slash it when a closing tag exists. IFRAME isn't empty BTW. That's why it has a closing tag.

You mean right as in valid? The validators don't complain for some reason, that's why I'm puzzled. unsure.gif

QUOTE
The choice between closing tag and slash only exists for real empty elements that have no closing tag in HTML. Adding a closing tag to those isn't compatible with all browsers so that leaves us with the ugly slash anyway.

That's what I thought too.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 17 2010, 10:45 PM
Post #9


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,402
Joined: 9-August 06
Member No.: 6



I don't know what's up with that.

Go validate this.

CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
  
<h1 />
<blockquote />
<p />

</body>
</html>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Jan 18 2010, 03:42 AM
Post #10


WDG Member
********

Group: Root Admin
Posts: 8,316
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



Yeah, basically, the XHTML validator doesn't know the difference between elements that should be empty like <br /> and <img />, and elements that shouldn't be empty like <h1 /> and <blockquote /> and <p /> and <iframe />.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jan 18 2010, 03:58 AM
Post #11


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,402
Joined: 9-August 06
Member No.: 6



Oh dear. I suspected that but didn't dare to say it. tongue.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 16th October 2019 - 02:14 PM