GWT inject script element into the html file

后端 未结 4 793
予麋鹿
予麋鹿 2021-02-05 23:51

On my gwt project. i have a script that call the dictionary:


i

4条回答
  •  一向
    一向 (楼主)
    2021-02-06 00:06

    Basically you inject the script element in your onModuleLoad():

        Element head = Document.get().getElementsByTagName("head").getItem(0);
        ScriptElement sce = Document.get().createScriptElement();
        sce.setType("text/javascript");
        sce.setSrc("conf/iw_dictionary.js");
        head.appendChild(sce);
    

    The browser will automatically load it as soon as it's injected.

提交回复
热议问题