Betty_S Posted February 28, 2007 Share Posted February 28, 2007 I have an interesting question:Can I insert this <h1><a href=”blablabla”> blablabla </a></h1> directly on the begging/top/first line of the <body>,Is that possible via JS?Thanks. Link to comment Share on other sites More sharing options...
jesh Posted February 28, 2007 Share Posted February 28, 2007 Perhaps something like this: <html><body><div>Some Content</div><script>var h1 = document.createElement("h1");var a = document.createElement("a");a.href = "blablabla";a.appendChild(document.createTextNode("blablabla"));h1.appendChild(a);document.body.insertBefore(h1, document.body.firstChild);</script></body></html> Check out the XML DOM Tutorial for more info. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now