Chrome扩展程序帮助-将打开页面的网址添加到manifest.json中default_popup的html中的过程是什么? [英] Chrome extension help - what's the process for adding the url of an open page to the html of the default_popup in manifest.json

查看:227
本文介绍了Chrome扩展程序帮助-将打开页面的网址添加到manifest.json中default_popup的html中的过程是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下清单:

{
    "name":"Fix the Web extension",
    "version":"0.2",
    "manifest_version":2,
    "description":"Web accessibility Poorly designed websites can exclude some disabled people. If disabled people report problems and volunteers push for improvements, Fix the Web crowdsources change.",
    "browser_action": {
        "default_icon": "FTW-favicon-128.png",
        "default_title": "Fix the Web | Disabled people: Report an issue now!",
        "default_popup": "extension.html"
        },
    "icons":{
        "128": "FTW-favicon-128.png"
    }
}

这将打开此html页面:

which opens this html page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>Disabled people: Report an issue now! | Fix the Web</TITLE>
</HEAD>
<body>
<iframe src="http://www.fixtheweb.net/frame/report" height="350" width="300"></iframe>
</body>
</HTML>

但是我想要添加?url = http://www.mysite.com/something在iframe链接中变为:

but what I want is to add ?url=http://www.mysite.com/something in the iframe link so it becomes:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
   "http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>Disabled people: Report an issue now! | Fix the Web</TITLE>
</HEAD>
<body>
<iframe src="http://www.fixtheweb.net/frame/report?url=http://www.mysite.com/something" height="350" width="300"></iframe>
</body>
</HTML>

我看过其他相关文章,但我觉得有些愚蠢-我认为这与ajax或javascript ...有关.非常感谢,这是有充分理由的(fixtheweb.net是网络无障碍慈善事业),因此会提供额外的业障积分:)

I've seen other related posts but I'm feeling a bit stupid - I think it has something to do with ajax or javascript.... help much appreciated, and it's for a good cause (fixtheweb.net is a web accessibility charity) so comes with bonus karma points :)

推荐答案

extension.js

chrome.tabs.query({active:true,currentWindow:true},function(tabArray){
    document.getElementById("eltId").src
        = "http://www.fixtheweb.net/frame/report?url="+tabArray[0].url;
});

,然后将"permissions": ["activeTab"]添加到清单中.然后,要从extension.html加载它,您将需要:

and add "permissions": ["activeTab"] to your manifest. Then, to load it from extension.html, you'll need:

<body>
 <iframe id="eltId" src="http://www.fixtheweb.net/frame/report" height="350" width="300"></iframe>
 <script type="text/javascript" src="extension.js"></script>
</body>

老实说,我感到惊讶的是它并没有花更多的钱.

I'm honestly surprised it didn't end up taking more.

这篇关于Chrome扩展程序帮助-将打开页面的网址添加到manifest.json中default_popup的html中的过程是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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