未定义编码 URI 组件

EncodeURIcomponent is not defined

本文关键字:组件 URI 编码 未定义      更新时间:2023-09-26

我在GreaseMonkey沙盒中玩,试图制作一个脚本,将加载的页面转发到另一台服务器,以便通过POST进行处理。下面是脚本:

// ==UserScript==
// @name        Mirror Page
// @namespace   mailto:linkhyrule5@gmail.com
// @description POSTs page to dynamic page mirror
// @include     http://*
// @include     https://*
// @version     1
// @grant       GM_xmlhttpRequest
// ==/UserScript==
var ihtml = document.body.innerHTML;
GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://localhost:5723/index.php',
    data: "PageContents=" + encodeURIcomponent(ihtml) + "'nURL=" + encodeURIcomponent(document.URL),
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});

不知何故,我越来越encodeURIcomponent is not defined,即使它是一个全局函数,应该在 JavaScript 所在的任何地方可用。我想我误解了什么?

你忘了大写字母C...就像骆驼案:

var ihtml = document.body.innerHTML;
GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://localhost:5723/index.php',
    data: "PageContents=" + encodeURIComponent(ihtml) + "'nURL=" + encodeURIComponent(document.URL),
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});