Code:
insertedText.innerHTML = "Inserted Text"
Only works in Internet Explorer! The W3C way (OK, sorta):
Code:
document.getElementById('insertedText').innerHTML = "Inserted Text"
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>untitled</title>
<style type="text/css">
p {font: 600 16px verdana; color: #6699cc;}
</style>
<script type="text/javascript" language="javascript">
function insert_it(what, where)
{
where = document.getElementById(where);
where.innerHTML = what;
}
var imgtag = '<img src="http://www.sitepointforums.com/images/icons/icon6.gif">stuff';
</script>
</head>
<body>
<p></p>
<p>
i just want to add it to the <span id="poke">
<img src="http://www.sitepointforums.com/images/icons/icon5.gif"></span> already on the page.
</p>
<input type="button" value="stuff" onclick="insert_it(this.value,'poke')">
<input type="button" value="junk" onclick="insert_it(this.value,'poke')">
<input type="button" value="incredible mishmash" onclick="insert_it('<i>' + this.value + '</i>','poke')">
<input type="button" value="HTML" onclick="insert_it('<small>' + this.value + '</small>','poke')">
<input type="button" value="kewl" onclick="insert_it(imgtag,'poke')">
</body>
</html>
Bookmarks