繁体   English   中英

在iframe中加载HTML页面

[英]Load html page in iframe

今天,我发现了一种非常奇怪的代码结构方法(对我而言)。 网站页面使用iframe进行自我调用。 我的问题是:值得吗? 可能是因为安全问题? 提前谢谢大家

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Azerbaijan Technical University</title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <style>
        html, head, body, iframe{
            width:100%;
            height:100%;
            margin:0;
            padding:0;
            border:none;
            overflow:hidden;
        }
    </style>
</head>
<body>
        <iframe id="frm" name="frmn" src="/" onload="location.hash = this.contentWindow.location.href.replace(this.contentWindow.location.origin,'');"></iframe>
    <script type="text/javascript">
        if (location.hash && location.hash != '') {
            document.getElementById('frm').src = location.origin + location.hash.replace("#","");
        }
        else {
            document.getElementById('frm').src = "main.do"; //"/login";//
        }
    </script>
</body >
</html >

如今,不建议使用iframe,即使Facebook和google也不允许您将其网站放置在iframe中。 您使站点容易受到跨站点攻击。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM