I think it is an easy questions but I am new in JavaScript
Why buttons "but3" and "but4" not working when I try moveBy or moveTo a new window?
thanks
HTML code
<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 code
开发者_开发问答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);
}
The error message says
Permission denied to access property 'moveBy'
To access the properties of another window, it needs to be in the same domain.
Your code works if you replace www.google.com with a file in the same directory.
精彩评论