www.webdeveloper.com
Results 1 to 15 of 15

Thread: why i can't put google.com inside iframe ?

  1. #1
    Join Date
    Jun 2010
    Posts
    3

    why i can't put google.com inside iframe ?

    i tried to create iframe which src=http://www.google.com
    and when i run the page it jump me to google (like someone click on link to google)
    btw
    i think it only happens in win 7

    any ideas?

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    post your code

  3. #3
    Join Date
    Jun 2010
    Posts
    3
    Quote Originally Posted by Kor View Post
    post your code
    <body>
    <iframe src="http://www.google.com"></iframe>

    </body>

  4. #4
    Join Date
    Jun 2010
    Posts
    13
    I had this problem once with myspace, if i had myspace as my iframes src it redirected the actual page containing the irame to myspace.

    I never solved it though.

    Thoguht i might share this lol

  5. #5
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    I don't see where is the problem. The below code works for me in all the browsers I have (IE6, IE7, IE8, FF 3,6, Opera 10, Chrome, Safari[for Win] on XP/SP3)
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    </head>
    <body>
    <iframe src="http://www.google.com"></iframe>
    </body>
    </html>
    So?

  6. #6
    Join Date
    Jun 2010
    Posts
    3

    Talking

    like I said it Is Happen to me only on win 7

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by splitme View Post
    like I said it Is Happen to me only on win 7
    If you have Win 7 (I don't), you probably have IE8. Try this:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    </head>
    <body>
    <iframe src="http://www.google.com"></iframe>
    </body>
    </html>
    And copy exactly my code above. Your document needs a Doctype by all means.

    Does this happen on FireFox as well as in IE8? Do you have installed some filters, either in Win7 or straight in IE8? have you changed the initial settings or preferences in IE8?

  8. #8
    Join Date
    Jun 2010
    Posts
    64
    It is possible for websites to try to break out of frames using javascript.
    However, google doesn't implement any frame breaker so it must a browser thing at your end.

    Sites can use this to stop frame viewing (I use it on my site):
    Code:
    if (window.top != self)
    	window.top.location = self.location.href;
    But it is possible to stop it breaking out. If on the page you put a onbeforeunload event, you'll get alerted before it escapes:
    Code:
    window.onbeforeunload = function()	{
    				return "The frame is escaping!!\nLet it go free?";
    			};
    So see if this is able to stop it:
    Code:
    <body onbeforeunload='function(){return "The frame is escaping!!\nLet it go free?";}'>
    <iframe src="http://google.com"></iframe>
    </body>

  9. #9
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,219
    I always liked using the object tags:

    Code:
    <div id="wrap"><object type="text/html" data="http://www.google.com/"></object></div>
    Style the div wrap as you need it.

  10. #10
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by Major Payne View Post
    I always liked using the object tags:

    Code:
    <div id="wrap"><object type="text/html" data="http://www.google.com/"></object></div>
    Style the div wrap as you need it.

    Unfortunately the <object> tag is not interpreted in the same way by all the browsers. It is incomplete or weird implemented so far.

  11. #11
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,219
    Quote Originally Posted by Kor View Post
    Unfortunately the <object> tag is not interpreted in the same way by all the browsers. It is incomplete or weird implemented so far.
    Never checked that. The w3c recommends the objects tags and not the embed tag (only one used). I've checked the use of the object code in Firefox and IE and it worked fine for me. Guess, when I get time, I'll try an example page at browsershots.

  12. #12
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    IE has serious security problems with <object> tag, thus usually IE has some restrictions wile running it. See:
    http://www.coresecurity.com/content/...ty-zone-bypass
    There are reported also cases when using ActiveX to attach events to an object tag will corrupt the memory...

    As I said, IE has some problems to interpret the <object> tag in a standard manner. W3C may recommend whatever - but if browsers do not follow or have problems in implementing the recommendation, the result will be the same: lack of cross-browser compatibility.

  13. #13
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,219
    Seems that that would have been fixed by now:

    Microsoft has issued a patch to fix the vulnerability and a detailed description of how to implement the workarounds on IE. It is available as Security Bulletin http://go.microsoft.com/fwlink/?LinkID=150860.
    I understand the problems with IE and always have, but I go by what is recommended by the w3c.org in hopes that some day we all will be on the "same page". Personally, I would like to see browser developers quit making browsers backwards compatible. Sure, that would break millions of web sites, but those can be updated to proper web standards. Those who want to continue viewing their sites with old colde can use old browsers. No comment needed as I know this is not a viable idea nor will ever be implemented. :P

  14. #14
    Join Date
    Jun 2005
    Location
    United Kingdom
    Posts
    1,043
    Quote Originally Posted by Major Payne View Post
    ....I understand the problems with IE and always have, but I go by what is recommended by the w3c.org in hopes that some day we all will be on the "same page"......
    Understandable - and I do think all sites should be written to W3c standards - though there are times when it gets beyond worthwhile - eg embedding a Flash video. But any commercial site has to take into account IE - and I am still doing so for IE6 (though I will review IE6 use of my sites at the end of the year).

  15. #15
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,219
    Hopefully IE 9, once released, will solve a lot of these problems for those who use IE. Then it will only be dependent on convincing people to "upgrade" their browser.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles