Help with Iframes
#1
Hello,

I need to embed website in another.
This is the syntax I'm using

<iframe src="http://*********.com" width="100%" height="100%" seamless></iframe>

Unfortunately it's not displaying at 100 percent length and width in the browsers... An I have scroll bars.

What's the correct syntax to use?
Reply
#2
iframes are kinda stupid. If you want it to be the exact size of the website you have to basically read the size of the content and then change the width / height of the iframe to match it. You should be able to google and find how to do this.
Reply
#3
Not what you asked. But, here is one possible alternative using PHP. (untested)
Source.
Code:
$home = file_get_contents('example.com');
echo $home;
You will need to install and if I recall right, _configure_ PHP on your system. It isn't too difficult. Similar solutions are possible if you are open to Perl/Python (CGI programs).

As for iframe, I think ViperScale is right. But I have no idea how to go about it. Maybe XmlHttpRequest ?
http://www.w3schools.com/xml/xml_dom.asp
Reply
#4
You could read the w3school for tips first. http://www.w3schools.com/tags/tag_iframe.asp

Seems like height doesnt allow for the use of percent (cant seem to get it to work in their example pages), but it seems like <iframe> works with CSS, so try that instead
Reply
#5
http://stackoverflow.com/questions/81941...tent-in-it

(code is a bit dated but follow the link and there is some links to some ways to fix it in newer browsers (etc) but it is the basic method for doing it)
Code:
<script language="JavaScript">
<!--
function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";
}
//-->
</script>

<IFRAME SRC="usagelogs/default.aspx" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>
Reply
#6
(Feb 14, 2014, 02:34 am)ViperScale Wrote: http://stackoverflow.com/questions/81941...tent-in-it

(code is a bit dated but follow the link and there is some links to some ways to fix it in newer browsers (etc) but it is the basic method for doing it)
Code:
<script language="JavaScript">
<!--
function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";
}
//-->
</script>

<IFRAME SRC="usagelogs/default.aspx" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>


Actually what I did was mirror a site by going with with an entire php script and rewrite on .htaccess

If anyone's interested I'll post the php script and the .htacess mod
Reply
#7
To me, the problem definition is not very clear. No problem. :-)
It reminds of the XY problem, where one attempts to solve problem 'X', by doing 'Y'.

If the code is not too long, you could post it I think. Perhaps it will be useful to someone searching for a solution.
Maybe there is a better solution too or someone would suggest improvements.
Reply
#8
(Feb 15, 2014, 00:39 am)SectorVector Wrote: To me, the problem definition is not very clear. No problem. :-)
It reminds of the XY problem, where one attempts to solve problem 'X', by doing 'Y'.

If the code is not too long, you could post it I think. Perhaps it will be useful to someone searching for a solution.
Maybe there is a better solution too or someone would suggest improvements.

Actually I just discovered that I only got "most" of the script working. I'll post the finished product when I get it done.
Reply
#9
Quote: overflow: hidden;
Reply
#10
Ok here's the script I started with :

Code:
<?php
// enter your site names here. The core url ONLY  NO http or slashes
$wc_source = "************.com";
$wc_mirror = "**************.com";
$sql = $_GET['sql'];
$URL = "http://".$wc_source."/".$sql;
$fullPath = $URL;
$base = '<base href="'.$URL.'">';
$host = preg_replace('/^[^\/]+\/\//','',$URL);
$tarray = explode('/',$host);
$host = array_shift($tarray);
$URI = '/' . implode('/',$tarray);
$content = '';
$fp = @fsockopen($host,80,$errno,$errstr,30);
if(!$fp) { echo "Unable to open socked: $errstr ($errno)\n"; exit; }
fwrite($fp,"GET $URI HTTP/1.0\r\n");
fwrite($fp,"Host: $host\r\n");
if( isset($_SERVER["HTTP_USER_AGENT"]) ) { fwrite($fp,'User-Agent: '.$_SERVER["HTTP_USER_AGENT"]."\r\n"); }
fwrite($fp,"Connection: Close\r\n");
fwrite($fp,"\r\n");
while (!feof($fp)) { $content .= fgets($fp, 128); }
fclose($fp);
if( strpos($content,"\r\n") > 0 ) { $eolchar = "\r\n"; }
else { $eolchar = "\n"; }
$eolpos = strpos($content,"$eolchar$eolchar");
$content = substr($content,($eolpos + strlen("$eolchar$eolchar")));
$content = str_replace($wc_source,$wc_mirror,$content);
// replaces paths with / in the begining without full url. not required unless you are in subfolder
$content = str_replace('href="/','href="http://'.$wc_mirror.'/',$content);
$content = str_replace('src="/','src="http://'.$wc_mirror.'/',$content);

// $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    
    // Determine Content Type
    switch ($ext) {
      case "pdf": $ctype="application/pdf"; break;
      case "exe": $ctype="application/octet-stream"; break;
      case "zip": $ctype="application/zip"; break;
      case "doc": $ctype="application/msword"; break;
      case "xls": $ctype="application/vnd.ms-excel"; break;
      case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
      case "gif": $ctype="image/gif"; break;
      case "png": $ctype="image/png"; break;
      case "jpeg": $ctype="image/jpg"; break;
      case "jpg": $ctype="image/jpg"; break;
      case "js": $ctype="text/javascript"; break;    
      case "css": $ctype="text/css"; break;
    }

    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers
    header("Content-Type: $ctype");
    header("Content-Transfer-Encoding: binary");
//    header("Content-Length: ".$fsize);
    

if( preg_match('/<head\s*>/i',$content) ) { echo( preg_replace('/<head\s*>/i','<head>'.$base,$content,1) ); }
else { echo ( str_replace($wc_source,$wc_mirror,preg_replace('/<([a-z])([^>]+)>/i',"<\\1\\2>".$base,$content,1) ));
}
?>

Here's the .htaccess
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?sql=$1 [L]
</IfModule>
Reply




Users browsing this thread: 2 Guest(s)