Last Active: May 13, 2014
Threads: 36
Posts: 213
Reputation:
8
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?
Last Active: Dec 02, 2014
Threads: 12
Posts: 240
Reputation:
8
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.
Last Active: Jun 04, 2024
Threads: 157
Posts: 2,039
Reputation:
29
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
Last Active: Sep 13, 2024
Threads: 18
Posts: 684
Reputation:
4
Feb 11, 2014, 13:12 pm
(This post was last modified: Feb 11, 2014, 13:17 pm by Q91. Edited 4 times in total.)
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
Last Active: Dec 02, 2014
Threads: 12
Posts: 240
Reputation:
8
Feb 14, 2014, 02:34 am
(This post was last modified: Feb 14, 2014, 02:45 am by ViperScale. Edited 2 times in total.)
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>
Last Active: May 13, 2014
Threads: 36
Posts: 213
Reputation:
8
(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
Last Active: Jun 04, 2024
Threads: 157
Posts: 2,039
Reputation:
29
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.
Last Active: May 13, 2014
Threads: 36
Posts: 213
Reputation:
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.
Last Active: Aug 07, 2024
Threads: 9
Posts: 99
Reputation:
12
Last Active: May 13, 2014
Threads: 36
Posts: 213
Reputation:
8
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>
|