Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximize iFrame (so it appears to be the request page)

Tags:

html

css

iframe

how can I (cross-browser compatible) maximize an iFrame so that it appears to be the page in the URL bar even though it is served from a different server?

like image 230
Alex Avatar asked Jan 23 '23 08:01

Alex


2 Answers

I guess this ought to work:

<!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>Test page!</title>
  <style type="text/css">
     html, body {
        overflow: hidden;
        margin: auto;
        height: 100%;
        width: 100%;
     }
  </style>
 </head>
 <body>
  <iframe src="page.htm" width="100%" height="100%" frameborder="0"></iframe>
 </body>
</html>

Edit 1: You could just hide the scrollbars of the page, with the HTML and scroll=no directive
(that solution should be multi-browser)

Edit 2: Now even XHTML proof ;)

Edit 3: And finally w3 validator ok
(be sure to add scroll=no in the BODY if you run in Internet Explorer compatibility problems)

like image 170
Zyphrax Avatar answered Jan 25 '23 21:01

Zyphrax


Use javascript with the event body load to set iframe height & width to window height & width.

For example in jquery :

$(document).ready(function () {
    initIframe();
});
function initIframe() {
    $("iframe").height($(window).height());
    $("iframe").width($(window).width());
}

Tested on FF, IE and GC

like image 26
Aelios Avatar answered Jan 25 '23 22:01

Aelios