Can I place something like the code below in a html page, and have the coolstuff.js render content to the page? I think i’ve seen it done…what is this technique called? Any pointers?
<form id="form1" runat="server">
<div>
<script src="coolstuff.js"
param1="Monkeys" param2="Go" param3="Nutz"
type="text/javascript"/>
</div>
</form>
Yes you can have a JS script place elements in the DOM of an HTML page.
The script doesn’t know anything about its “position” in an HTML page: you’ll have to “place” your elements yourself by referencing a position in the DOM.
In your example above, you’ll have to find the position relative to the “script” tag with your script and then add childs etc. You can use the
getEementsByTagNameto find your “script” tag for example.Even better, use
getElementByIdwith<script id="someid" ...>to find the relative position.