如何使用隐藏的iframe连接到GreaseMonky中的服务器 [英] How to use hidden iframe connect to the server in GreaseMonky

查看:154
本文介绍了如何使用隐藏的iframe连接到GreaseMonky中的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我创建了一个这样的隐藏框架:

First,I created a hidden frame like this:

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,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


推荐答案

没有这样的东西,如 document.frames 名称 -indexed框架数组是 window.frames (也就是框架)。

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

0-iframe是如此古老的学校,这些日子大多与恶意软件安装漏洞(特别是在中文页面上)有关。如何使用XMLHttpRequest?

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?

这篇关于如何使用隐藏的iframe连接到GreaseMonky中的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆