我可以从父页面验证iFrame页面吗?

Jam*_*een 4 html javascript authentication iframe

我有一个简单的HTML页面,可以旋转几个状态页面,我在校园周围的几个电视上显示.我定期更新页面和链接.很多时候页面需要身份验证.远程终端提供凭证是一种痛苦.一些是HTTP身份验证,一些是<form>基于身份验证的网站.很多时候,我可以通过<form>发布正确凭据的HTML和JavaScript来解决基于身份验证的问题.

  1. 有没有更好的方法来<form>从主机页面绕过基于身份验证?(下面)

  2. 有没有办法从主机页面绕过基于服务器/ HTTP的身份验证,而无需在显示器上手动进行身份验证?

通过<form>身份验证我的意思是一个<form>动作生成一个会话cookie?
(mikerobi,感谢评论)

这是主页的代码

<!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" >
<head>
<title> 
  Important Stuff 
</title>
    <script src="/scripts/jquery.js" type="text/javascript"></script>
    <style type="text/css">
        html, body, iframe { margin:0; height:100%; }
        iframe { display:block; width:100%; border:none; }
    </style>
    <script type="text/javascript">
        var link = new Array();        
        link[0] = "http://mycompany.intranet/";        
        link[1] = "http://mycompany.intranet/weather.htm";        
        link[2] = "http://mycompany.intranet/systemstatus/";        
        var linkIndex = 0;
        setInterval("doSomething()", 10000);

        function doSomething() {

            if (linkIndex >= link.length)
            {
                // reload in case the page has been updated
                window.location.reload();
            }

            $("#frame").attr("src", link[linkIndex]);
            linkIndex++;
        }
    </script>
</head>
<body>
    <iframe id="frame" src="http://mycompany.intranet/"></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Ple*_*and 8

  1. 我没有看到您的代码发送基于POST的登录的凭据,但如果您使用JavaScript自动提交表单(使用其.submit()方法),这可能是最好的方法.请注意,targetHTML表单的属性允许您在不同的窗口(或者在您的情况下,iframe)中提交表单 - 只需为iframe提供一个name="xyz"属性并target="xyz"用于表单.表单将位于主页中,可以使用CSS隐藏display: none.

  2. 您可以在URL中包含HTTP Basic Auth用户名和密码,例如:http://username:password@www.example.com/path.需要注意的是当前Web浏览器可能不会允许这样的默认配置为针对特定的网络钓鱼技术保障措施,并且你可能要更改配置通过编辑Windows注册表或其他地方存储Web浏览器设置.