在这里,我有一个呈现某些内容的主页(index.html)。导航到all.html时,无法使用onload事件更改页面的内容。其他事件(例如onclick)也可以正常工作。我找不到错误。谢谢。
index.html
<script src="./js/main.js"> </script>
<script src="./js/try.js"> </script>
</head>
<body>
<div class="cssload-container">
<div class="cssload-whirlpool"> </div>
</div>
<ons-navigator id="mainNavigator" page="splitter.html"> </ons-navigator>
<ons-template id="splitter.html">
<ons-page>
<ons-splitter id="mainSplitter" side="left" swipeable collapse="portrait" width="200px" >
<ons-splitter-side page="menu.html" id="menu" side="left" width="260px" height="9.2em" swipe-target-width="150px" collapse swipeable>
</ons-splitter-side>
<ons-splitter-content id="content" page="home.html">
</ons-splitter-content>
</ons-splitter>
</ons-page>
</ons-template>
main.js
ons.ready() {
console.log("Onsen UI is ready!");
});
<!-- Some unrelated code -->
all.html
<ons-page id="all_courses.html" onload="uis()">
<p> hy </p>
</ons-page>
try.js
function uis()
{
document.getElementById("all_courses.html").innerHTML = "<h1> Hello </h1>";
}
/*P.S. : I tried windows.onload = func;
func() { document.getElementById("all_courses.html").innerHTML = "<h1> Hello </h1>"; }
addEventListener('load', func, false) */