我试图创建一个窗口并动态更改其属性。无法使用javascript更改窗口对象的属性
但是当我加载一个网页(例如:www.google.com):加载完美;并按下“红色”按钮,窗口向后移动并且不会改变其背景颜色。
这里是我的代码:
的JavaScript:
var win1 ='';
function create(){
var url1=document.getElementById('myUrl').value;
win1=open(url1,'hello', 'width=500,height=500');
}
function makeItRed(){
win1.document.body.style.backgroundColor="red";
win1.focus();
}
function closeIt(){
win1.close();
}
HTML:
<input type="text" id="myUrl"/>
<button onClick="create()">Click</button>
<button onClick="makeItRed()">Red</button>
<button onClick="closeIt()">close</button>
[链接](http://stackoverflow.com/questions/2157180/onclick-open-window-and-specific-size)回到这个。 –
是否有任何错误记录在控制台中?框架受到[相同来源策略](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript)的限制,这将阻止修改您不拥有的资源。 –
谢谢@Atal,但我需要在加载后更改属性。 :( – Charls