启动html ----------------------
div id="pageWrapper"> //page wrapper
<div id="page-image"><img src="./images/lightHouseB.png"></div>
<div id="man-image"><img src="./images/sailor.png"></div>
<section>
<header>There Are Things in the Dark, can you Find them? </header>
<!-- basic html title page -->
<div id="textBox">
<a id="mousee" href="#">Hidden Ships</div></a>
</div>
</section>
html结束点-----------------------------------
window.onload = eventMonitor();
function eventMonitor(){
document.getElementById('manimage').addEventListener('onmouseover', popMap(), false);
document.getElementById('mousee').addEventListener('click', shipsSlider(), false);
function popMap(url='shipsSlide.html',windowName, w, h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
return window.open(url=" ", "Ship Pictures", toolbar='no', directories="no", status='no');
}
不断获取null值 - 无法读取eventlistener的null属性。
答案 0 :(得分:1)
您需要将函数引用到window.onload
,并在窗口加载后调用它。
在这里看到差异。
window.onload = onload;
function onload(){
console.log('DOM loaded');
}
在这里我引用任何onload
将返回的内容,在本例中是一个函数。
window.onload = onload(); // This will return the anonymous function of onload
// __________________|^^|
function onload(){
return function(){
console.log('DOM loaded');
}
}
所以你要做的就是删除()
,以便你的代码成为:
window.onload = eventMonitor; // eventMonitor will be run once windows loads.