用PHP写一个 内嵌框架展示访问httpstx2ntopshopuser这个网址要求窗口自适应写出多种方法方案
方案一:
<!DOCTYPE html>
<html>
<head>
<title>嵌入页面展示</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<iframe src="https://tx2n.top/shop/user/" width="100%" height="100%" frameborder="0"></iframe>
</body>
</html>
方案二:
<!DOCTYPE html>
<html>
<head>
<title>嵌入页面展示</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
iframe {
width: 100%;
height: 100%;
border: none;
}
</style>
</head>
<body>
<iframe src="https://tx2n.top/shop/user/"></iframe>
</body>
</html>
方案三:
<?php
$url = "https://tx2n.top/shop/user/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
方案四:
<?php
$url = "https://tx2n.top/shop/user/";
$html = file_get_contents($url);
echo $html;
?>
以上四种方案都可以实现内嵌框架展示网页,并且窗口自适应。方案一和方案二使用了iframe标签,并设置了宽度和高度为100%;方案三和方案四则使用了PHP的curl和file_get_contents函数获取网页内容,再直接输出到当前页面中。需要注意的是,方案三和方案四可能会因为目标网站的安全设置而无法获取内容
原文地址: http://www.cveoy.top/t/topic/fEex 著作权归作者所有。请勿转载和采集!