Is There A Way To Change The Title Of An Html Page While It Opens An Xml File?
I have an xml file called file.xml, I want to know how to change the title of the html page that xml file is open in. For example, if I have the following link in my html file: <
Solution 1:
Like this
It will not popup in a snippet but try it on a server
https://plungjan.name/SO/framewindow/
document.getElementById("container").addEventListener("click", function(e) {
const tgt = e.target;
if (tgt.classList.contains("link")) {
const w = window.open("", "_blank");
if (w) { // popup not blockedconst html = `<title>${tgt.title}</title><body style="margin:0; padding:0"><iframe style="height:100%; width:100%; border:0" src="${tgt.href}"></iframe></body>`
e.preventDefault();
w.document.write(html);
w.document.close();
}
// else let the link work on its own
}
})
<divid="container"><aclass="link"title="File #1"href="https://www.google.com/search?q=file1.xml">File1.xml</a><aclass="link"title="File #2"href="https://www.google.com/search?q=file2.xml">File2.xml</a></div>
Post a Comment for "Is There A Way To Change The Title Of An Html Page While It Opens An Xml File?"