开发者

How to use hidden iframe connect to the server in GreaseMonky

First,I created a hidden frame like this:

var oHiddenFrame = null;
if(oHiddenFrame == null){
  oHiddenFrame = document.createElement("iframe");
  oHiddenFrame.name = "hiddenFrame";
开发者_JS百科  oHiddenFrame.id = "hiddenFrame";
  oHiddenFrame.style.height = "0px";
  oHiddenFrame.style.width = "0px";
  oHiddenFrame.style.position = "absolute";
  oHiddenFrame.style.visbility = "hidden";
  document.body.appendChild(oHiddenFrame);
}

Then,I add a event to the button like this:

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

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

When I click the button,I got a error:

frames.hiddenFrame is undefined


There's no such thing as document.frames. The name-indexed frame array is window.frames (aka just frames).

0-iframes are so old-school, and these days mostly associated with malware-installing exploits (especially on Chinese pages). How about using an XMLHttpRequest instead?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜