开发者

Why the js code works in a web page but fails in GreaseMonkey?

I created a hidden frame as follows:

var oHiddenFram开发者_Go百科e = 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);
}

then listener:

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

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

It works fine in a web page,but will report frames.hiddenFrame is undefined when written in GreaseMonkey


Have you tried,

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜