简体   繁体   中英

pull addContentHTML content from XML or HTML file

I have created a js dialog window, which shows some HTML (below). My problem is, instead of simply hard-coding the shown content as a html string, I want to keep the text content in a separate XML or HTML, which is then pulled into the dialog by addContentHTML. How is that done?

Best regards

createDialog: function () {
    this.dialog = new Dialog({
        title: 'Version info', 
        id:'version_window', 
        resizable: true,
        width: 420
    });
    this.dialog.addContentHTML('<b>Latest public version: </b>1.0</br></br><b>Currently testing:</b> 1.01</br></br>');
}

You can pull the content from any hidden element in the DOM:

<div id="content" style="display: none">
    ...
</div>

this.dialog.addContentHTML(document.getElementById('content').innerHtml);

There is more than on the way to do this, but this is the gist of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM