View Full Version : website link on HTML
NitroDev
10-25-2013, 01:43 PM
What is the <> for that?
EDIT: Found it but its only for <body> tag and i want to be in here:
function credit()
{
document.body.innerHTML="<pre><h3>These people helped me alot:<\/h3><br><br><a href="http://www.dynamicdrive.com/forums/"><\/pre>"
}
jscheuer1
10-26-2013, 02:01 PM
function credit()
{
document.body.innerHTML+='<pre><h3>These people helped me alot:<\/h3><br><br><a href="http://www.dynamicdrive.com/forums/">Dynamic Drive<\/a><\/pre>'
}
Notice that I changed the outer delimiting quotes from double (") to single (') so that the quotes inside the string would not be seen as ending the string. I also changed innerHTML= to innerHTML+=. That should add it to the body's HTML rather than overwrite the body's HTML. But the problem with that is, if you've assigned events to elements in the body or another script has, and/or there's a form involved, things might not work as expected. Also, if the existing HTML is invalid, this very often will cause problems in at least some browsers.
It's generally better to append an element to the body, then set its innerHTML to what you want it to be. In this case you could:
function credit()
{
var pre = document.createElement('pre');
document.body.appendChild(pre);
pre.innerHTML = '<h3>These people helped me alot:<\/h3><br><br><a href="http://www.dynamicdrive.com/forums/">Dynamic Drive<\/a>';
}
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.