0
我認爲這是一個簡單的問題,但我是新的JavaScript爲什麼moveBy和moveTo不能在我的代碼中工作?
爲什麼按鈕「but3」和「but4」不工作當我嘗試moveBy或moveTo一個新的窗口?
感謝
HTML代碼
<input type="button" value="New window" id="but1" onclick="createwin()" />
<input type="button" value="close window" id="but2" onclick="closewin()" />
<input type="button" value="moveby window" id="but3" onclick="movebywin()" />
<input type="button" value="moveto window" id="but4" onclick="movetowin()" />
JavaScript代碼
var win1;
function createwin(){
win1 = window.open('http://www.google.com','google','width=500,height=500');
}
function closewin(){
win1.close();
}
function movebywin(){
win1.moveBy(100,100);
}
function movetowin(){
win1.moveTo(100,100);
}