2009-11-03 8 views
0

J'ai créé un cadre caché comme suit:Pourquoi le code js fonctionne dans une page Web mais échoue dans 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); 
} 

puis auditeur:

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

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

Il fonctionne très bien dans une page Web, mais fera rapport frames.hiddenFrame is undefined lorsqu'il est écrit dans Greasemonkey

+1

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

Répondre

1

Avez vous avez essayé,

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

Essayé, ne fonctionne pas. – another

+0

fonctionne parfaitement pour moi. Je ne suis pas sûr de ce que nous manquons. –

Questions connexes