Google chrome extension 如何将HTML文件的内容从Chrome扩展动态添加到页面?

Google chrome extension 如何将HTML文件的内容从Chrome扩展动态添加到页面?,google-chrome-extension,Google Chrome Extension,从使用Chrome扩展名开始,有条件地将.html文件的内容添加到页面的最佳方式是什么。就像你不想总是添加它,只有在满足某些条件的情况下。我看到了有条件地注入脚本的方法,但是如何有条件地将扩展名中的文件中的HTML添加到页面中呢 如果我打开了一个选项,我想添加一段代码 阅读选项: this.get_options = function () { chrome.storage.sync.get({ mytopics: true, friendtopics:

从使用Chrome扩展名开始,有条件地将.html文件的内容添加到页面的最佳方式是什么。就像你不想总是添加它,只有在满足某些条件的情况下。我看到了有条件地注入脚本的方法,但是如何有条件地将扩展名中的文件中的HTML添加到页面中呢

如果我打开了一个选项,我想添加一段代码

阅读选项:

this.get_options = function ()
{
    chrome.storage.sync.get({
        mytopics: true,
        friendtopics: true
    }, function(items) {
        self.settings = items;
        scan_page();
    });
}

this.scan_page = function()
{
    if (!(self.settings.mytopics || self.settings.friendtopics))
        return;
    // want to add in a decent amount of HTML from a file, here.
    // don't really want to construct it all via createnode calles
}
我明白了

$('body').append('<div id="containerName"></div>');
$('#containerName').load(chrome.extension.getURL("markup/notification.html"));
$('body')。追加(“”);
$('#containerName').load(chrome.extension.getURL(“markup/notification.html”);