Code: Select all
**strong** and mark
gray
< /code>
markdown-it.js
Code: Select all
'use strict';
window.onload = function() {
const markdown = document.querySelector('noscript').innerHTML;
const md = window.markdownit({
html: true, linkify: false, typographer: true
});
const html = md.render(markdown);
document.querySelector('body').innerHTML = html;
}
< /code>
It works.
Now, I want that page to show my browser and IP time zones.
**strong** and mark
gray
​
< /code>
time-zones.js
Code: Select all
'use strict';
(async () => {
const displayEl = document.querySelector("#time-zones");
try {
displayEl.textContent =
Intl.DateTimeFormat().resolvedOptions().timeZone + " — " +
(await (await fetch(`https://ipapi.co/json`)).json()).timezone;
} catch ({message}) {
displayEl.textContent = 'Error: ' + message;
}
})();
< /code>
But this doesn't work. I mean, the time-zones.js
Code: Select all
window.onload = function() {
const markdown = document.querySelector('noscript').innerHTML;
const md = window.document.querySelector('noscript').markdownit({
html: true, linkify: false, typographer: true
});
const html = md.render(markdown);
document.querySelector('noscript').innerHTML = html;
}
< /code>
TypeError: window.document.querySelector('noscript').markdownit is not a function. (In 'window.document.querySelector('noscript').markdownit({
html: true, linkify: false, typographer: true
})', 'window.document.querySelector('noscript').markdownit' is undefined)