Javascript jQuery$(窗口)。在带有iFrame的页面上过早调用加载事件
我有一个JSF页面,可以在iFrame中显示另一个网站:Javascript jQuery$(窗口)。在带有iFrame的页面上过早调用加载事件,javascript,jquery,css,jsf,iframe,Javascript,Jquery,Css,Jsf,Iframe,我有一个JSF页面,可以在iFrame中显示另一个网站: <iframe id="frame" name="frame" style="display:none; width: 100%; height: 700px" scrolling="yes" /> 及 类似问题: 该“其他”网站是否在同一域中?否,其他网站是外部页面。 <form id="login" target="frame" method="post" action="LOGIN-URL">
<iframe id="frame" name="frame" style="display:none;
width: 100%; height: 700px" scrolling="yes" />
及 类似问题:
该“其他”网站是否在同一域中?否,其他网站是外部页面。
<form id="login" target="frame" method="post" action="LOGIN-URL">
<input type="hidden" name="username" value="Test"/>
</form>
<script type="text/javascript">
document.getElementById('login').submit();
var iframe = document.getElementById('frame');
iframe.onload = function() {
if (iframe.src.indexOf(REDIRECT-URL) == -1) {
iframe.src = REDIRECT-URL;
}
}
</script>
function changeStyle() {
document.getElementById("frame").className = "show";
document.getElementById("loading").className = "hide";
}
<script>
jQuery(window).load(function() {
changeStyle();
});
</script>
document.addEventListener('DOMContentLoaded', function() {
// your code here
}, false);
if(window.attachEvent) {
window.attachEvent('onload', yourFunctionName);
} else {
if(window.onload) {
var curronload = window.onload;
var newonload = function() {
curronload();
yourFunctionName();
};
window.onload = newonload;
} else {
window.onload = yourFunctionName;
}
}