-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhtmleditor.js
More file actions
21 lines (20 loc) · 743 Bytes
/
htmleditor.js
File metadata and controls
21 lines (20 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function changeHTML()
{
var iframe = document.getElementById('iframe-select');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var editor = ace.edit("editor");
innerDoc.documentElement.innerHTML=patchHTML(editor.getValue());
}
function patchHTML(input)
{
output=new DOMParser().parseFromString(input, "text/xml");
var all=output.querySelectorAll("*");
for(var i = 0, max = all.length; i < max; i++)
{
all[i].setAttribute("safeonmousedown",all[i].getAttribute("onmousedown") || "");
all[i].setAttribute("safehref",all[i].getAttribute("href") || "");
all[i]=tagify(all[i]);
}
console.log(output);
return new XMLSerializer().serializeToString(output);
}