小编Kos*_*nko的帖子

如何将消息发布到 iFrame 中?

我正在开发一个 Chrome 扩展程序以与我自己的 Web 应用程序一起使用,处理加载到iFrame我的应用程序主页上的网页(包括跨域页面)。所以我必须发送消息,包含要处理的页面的 URL,从我的主页面到内容脚本,注入目标iFrame以访问已处理页面的窗口。

我尝试实施这里描述的方法。以下是所有涉及的文件的基本部分:

index.html

...
<head>
    ...
    <script type="text/javascript" src="base.js"></script>
</head>
<body>
    <div>
        <input type="text" id="page_url">&nbsp;<input type="button" id="get_page" value="Get page">
    </div>
    <iframe id="cross_domain_page" src=""></iframe>
</body>
Run Code Online (Sandbox Code Playgroud)

base.js

(function() {
    "use strict";
    function pageProcessing() {
        let urlButton = window.document.getElementById("get_page");
        urlButton.addEventListener("click", () => {
            let url = window.document.getElementById("page_url").value;
            window.postMessage(
                {
                    sender: "get_page_button1",
                    message: url
                },
                "*"
            );
            window.postMessage(
                {
                    sender: "get_page_button2",
                    message: url
                },
                "*"
            );
        });
    }
    window.document.addEventListener('readystatechange', () => …
Run Code Online (Sandbox Code Playgroud)

javascript iframe postmessage google-chrome-extension content-script

10
推荐指数
1
解决办法
3万
查看次数

如何修复 VS Code 中的 pylint“无法识别的选项”错误?

发生事件后,我在 VS code 中重新安装了默认的 Python 扩展(适用于 Windows 10),并且 pylint 开始以一种非常奇怪的方式对我的项目中的任何 python 文件执行操作(请参阅下面的示例):

错误列表

Pylint 显然在这里起作用,因为第 4、5 和 7 行显示为正确的行,而第 1、9、10 和 11 行被标记为包含错误。

但这些错误列表对我来说看起来相当神秘:我无法理解在未更改的全新安装中,任何 pylint 选项如何可能无法识别或损坏?

有什么建议如何解决这个问题吗?

pylint visual-studio-code

5
推荐指数
2
解决办法
9523
查看次数