views:

53

answers:

1

I created a hidden frame as follows:

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);
}

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

+1  A: 

Have you tried,

document.getElementById('hiddenFrame').location.href = "http://meckmeck.cn";
Vijay Dev
Tried,not working.
another
works perfectly for me. Am not sure what are we missing.
Vijay Dev