Inject HTML into a page from a content script

后端 未结 5 1732
南旧
南旧 2020-11-28 23:35

I am building a Chrome Extension and I have a requirement to overlay a blob of html on top of a few websites. At the moment I am using a JQuery .Get to pull the

5条回答
  •  一向
    一向 (楼主)
    2020-11-29 00:27

    If you're using Angular in your Chrome extension, you can make use of ng-include

    var injectedContent = document.createElement("div");
    injectedContent.setAttribute("ng-include", "");
    //ng-include src value must be wrapped in single quotes
    injectedContent.setAttribute("src", "'" + chrome.extension.getURL("template.html") + "'");
    existingElement.appendChild(injectedContent);
    

提交回复
热议问题