Javascript 将登录凭据传递到iframe以进行自动登录
我想为超集创建自动登录页面,下面是我尝试的内容Javascript 将登录凭据传递到iframe以进行自动登录,javascript,jquery,iframe,superset,Javascript,Jquery,Iframe,Superset,我想为超集创建自动登录页面,下面是我尝试的内容 <form id="login" target="frame" method="post" action="http://superset.com/login"> <input type="hidden" name="username" value="login" />
<form id="login" target="frame" method="post" action="http://superset.com/login">
<input type="hidden" name="username" value="login" />
<input type="hidden" name="password" value="pass" />
</form>
<iframe id="frame" name="frame"></iframe>
<script type="text/javascript">
// submit the form into iframe for login into remote site
document.getElementById('login').submit();
// once you're logged in, change the source url (if needed)
var iframe = document.getElementById('frame');
iframe.onload = function() {
if (iframe.src != "http://superset.com/list") {
iframe.src = "http://superset.com/list";
}
}
</script>
//将表单提交到iframe以登录到远程站点
document.getElementById('login').submit();
//登录后,更改源url(如果需要)
var iframe=document.getElementById('frame');
iframe.onload=函数(){
如果(iframe.src!“http://superset.com/list") {
iframe.src=”http://superset.com/list";
}
}
这段代码在Firfox中运行得很好,但在chrome或Safri中却不起作用,我不知道为什么
框架打开,即使我尝试手动登录,也无法工作
我尝试从另一个窗口登录,它在chrome中工作,但会话没有被保存到iframe的浏览器中,即使它在Firfox中也能工作
有什么问题