xssbook/public/js/main.js

22 lines
456 B
JavaScript
Raw Normal View History

2023-01-26 22:29:16 +00:00
var range;
function add(html, id) {
const old = document.getElementById(id)
if (old !== null) {
old.remove()
}
if (range === undefined) {
var range = document.createRange()
range.setStart(document.body, 0)
}
document.body.appendChild(
range.createContextualFragment(html)
)
}
function remove(id) {
const old = document.getElementById(id)
if (old !== null) {
old.remove()
}
}