10 ms·
document.write is pretty wild, as it can modify the HTML token stream directly, e.g. <html> <script> document.write("<h"); </script>1> This i
by dbaupp 12y ago
document.write is pretty wild, as it can modify the HTML token stream directly, e.g.
<html>
<script>
document.write("<h");
</script>1>
This is a h1 title
<script>
document.write("<!-");
</script>-
This is commented
-->
</html>
(From http://www.reddit.com/r/rust/comments/2zir9s/html5ever_project_update_one_year/cpjbh77 http://www.reddit.com/r/rust/comments/2zir9s/html5ever_proje... )
- whoisthemachine 12y agoWhat?! Why. why. why would anyone ever need this, and why would it ever be made available? I'm just completely dumbfounded by this.
- Manishearth 12y agoApparently a lot of the older webpages do stuff like this. You could have a table being outputted by nesting for loops for the `<table>`, `<tr>`, and `<td>` opening/closing tags. It's a small step from here to constructing tags bit by bit. I don't see people doing it in modern websites (doesn't mean there aren't), but we sort of have to support all of the Internet, so...