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
Duplicata de http://stackoverflow.com/questions/1666860/how-to-use-hidden-iframe-connect-to-the-server-in-greasemonky? – npdoty