我有一段JavaScript不能在IE中正常运行的问题。其他所有平台都可以。

有一个简单的JavaScript,它带有一个系统值,并使用它来查看用户是否登录,并将HTML相应地放入div。但是,直到执行Ctrl-F5,它才会在IE中加载。

任何帮助都会很棒,因为我对此感到很困惑。

<div id="registered-output"></div>

<script type="text/javascript">

window.onload = loadScript();

function loadScript() {

var currentuser = window.parent._jive_current_user.displayName;
var useremail = window.parent._jive_current_user.username;

if (currentuser == 'ANONYMOUS') {
document.getElementById("registered-output").innerHTML = "<div class='register-container'><div class='register-header'><div class='register-header-holder'><p class='header-text'>Register</p></div><div class='register-toptext'><p class='header'>Why join our community?</p></div></div><div class='register-ul'><ul class='register'><li class='register-li'>Here's one good reason</li><li class='register-li'>Networking with others</li><li class='register-li'>Start or join a discussion</li><li class='register-li'>Tech notes</li><li class='register-li'>Networking with others</li></ul></div><div class='register-join'><a href='https://mentor.jiveon.com/create-account.jspa'><img src='http://mentor.jiveon.com/resources/statics/15536/join-here-smaller.png'></a></div></div>";
}
else if (currentuser != 'ANONYMOUS') {
document.getElementById("registered-output").innerHTML = "<div class='register-container-stuff'><div class='register-header'><div class='register-header-holder'><p class='header-text'>Personal Settings</p></div><div class='register-toptext'><p class='header'>Welcome " + useremail + "</p></div></div><div class='register-ul-two'><table><tr><td><img src='/resources/statics/15536/content.png'></td><td>&nbsp;</td><td><a target=_new href='people/" + window.parent._jive_current_user.username + "/content');'>Your Content</a></td></tr><tr><td><img src='/resources/statics/15536/activity.png'></td><td>&nbsp;</td><td><a target=_new href='people/" + window.parent._jive_current_user.username + "/activity');'>Your Activity</a></td></tr><tr><td><img src='/resources/statics/15536/connections.png'></td><td>&nbsp;</td><td><a target=_new href='people/" + window.parent._jive_current_user.username + "/people');'>Your Connections</a></td></tr><tr><td><img src='/resources/statics/15536/places.png'></td><td>&nbsp;</td><td><a target=_new href='people/" + window.parent._jive_current_user.username + "/places');'>Your Places</a></td></tr><tr><td><img src='/resources/statics/15536/bookmarker.png'></td><td>&nbsp;</td><td><a target=_new href='people/" + window.parent._jive_current_user.username + "/bookmarks');'>Your Bookmarks</a></td></tr></table></div></div>";
}
}

</script>


我已编写此代码以使其适合Jive平台上的HTML小部件。

最佳答案

您的密码

window.onload = loadScript();


是错的。您正在调用该函数,而不是对其进行分配。放下()

window.onload = loadScript;

10-07 21:15