2022-07-01 05:47:33 -03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2023-01-16 12:34:50 +01:00
|
|
|
<title>Test Dynamic Page</title>
|
2022-07-01 05:47:33 -03:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p>home page content</p>
|
|
|
|
<div id="content">
|
|
|
|
<a href="index.html" id="a1">link to index</a>
|
|
|
|
<a href="page_w_hidden_text.html" id="a2">link to page with hidden text</a>
|
|
|
|
<a href="page1.html" id="a3">link to page 1</a>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
const updateTimeout = setTimeout(myUpdateFunction, 150);
|
|
|
|
|
|
|
|
function myUpdateFunction() {
|
|
|
|
const remElem = document.querySelector('#a2');
|
2023-01-16 12:34:50 +01:00
|
|
|
if (remElem)
|
2022-07-01 05:47:33 -03:00
|
|
|
remElem.parentNode.removeChild(remElem);
|
|
|
|
|
|
|
|
if (!document.querySelector('#a4')) {
|
|
|
|
const newElem = document.createElement('a');
|
|
|
|
newElem.href = 'page2.html';
|
|
|
|
newElem.id = 'a4';
|
|
|
|
newElem.innerText = 'link to page 2';
|
|
|
|
document.body.appendChild(newElem);
|
|
|
|
}
|
|
|
|
|
|
|
|
clearTimeout(updateTimeout);
|
|
|
|
}
|
2023-01-16 12:34:50 +01:00
|
|
|
</script>
|
2022-07-01 05:47:33 -03:00
|
|
|
</body>
|
2023-01-16 12:34:50 +01:00
|
|
|
</html>
|