将数组的元素循环到一个变量中进行比较
loop the elements of an array into a variable for comparison
开始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');
}
不断获取空值 - 无法读取空事件监听器的 属性。
您需要将函数引用到 window.onload
,一旦 window 加载,它就会被调用。
看看这里的区别。
window.onload = onload;
function onload(){
console.log('DOM loaded');
}
这里我引用了 onload
将要 return 的任何内容,在本例中是一个函数。
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.
开始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');
}
不断获取空值 - 无法读取空事件监听器的 属性。
您需要将函数引用到 window.onload
,一旦 window 加载,它就会被调用。
看看这里的区别。
window.onload = onload;
function onload(){
console.log('DOM loaded');
}
这里我引用了 onload
将要 return 的任何内容,在本例中是一个函数。
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.