2009-11-03 46 views
0

我创建了一个隐藏的框架如下:为什么js代码在网页中工作,但在GreaseMonkey中失败?

var oHiddenFrame = null; 
if(oHiddenFrame == null){ 
oHiddenFrame = document.createElement("iframe"); 
oHiddenFrame.name = "hiddenFrame"; 
oHiddenFrame.id = "hiddenFrame"; 
oHiddenFrame.style.height = "0px"; 
oHiddenFrame.style.width = "0px"; 
oHiddenFrame.style.position = "absolute"; 
oHiddenFrame.style.visbility = "hidden"; 
document.body.appendChild(oHiddenFrame); 
} 

然后听众:

var fnLocation = function(){ 
frames["hiddenFrame"].location.href = "http://meckmeck.cn"; 
} 

var oButton = document.getElementById("mb_submit"); 
oButton.addEventListener("click", fnLocation, false); 

它正常工作,在一个网页,但写在的GreaseMonkey

+1

重复http://stackoverflow.com/questions/1666860/how-to-use-hidden-iframe-connect-to-the-server-in-greasemonky? – npdoty

回答

1

时有将报告frames.hiddenFrame is undefined你试过,

document.getElementById('hiddenFrame').location.href = "http://meckmeck.cn"; 
+0

试过了,没有工作。 – another

+0

适合我。我不确定我们缺少什么。 –

相关问题