Javascript 如何在GreaseMonky中使用隐藏的iframe连接到服务器
首先,我创建了一个隐藏帧,如下所示:Javascript 如何在GreaseMonky中使用隐藏的iframe连接到服务器,javascript,dom,greasemonkey,Javascript,Dom,Greasemonkey,首先,我创建了一个隐藏帧,如下所示: var oHiddenFrame = null; if(oHiddenFrame == null){ oHiddenFrame = document.createElement("iframe"); oHiddenFrame.name = "hiddenFrame"; oHiddenFrame.id = "hiddenFrame"; oHiddenFrame.style.height = "0px"; oHiddenFrame.style
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);
然后,我向按钮添加一个事件,如下所示:
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);
单击该按钮时,出现了一个错误:
frames.hiddenFrame is undefined
没有所谓的
document.frames
。名称
索引的帧数组是窗口。frames
(也称为justframes
)
0-iframes是如此老派,现在大多与恶意软件安装漏洞有关(尤其是在中文页面上)。改用XMLHttpRequest怎么样