FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

document.write in XHTML

 


lastelement0
hey all

i am currently in a web apps course where we are now learning javascript. we are using xhtml as opposed to html in our web page coding. we have come to learn that document.write is no longer supported when being used with xhtml. is there any "simple" method of getting this functionality in xhtml?

i read somewhere that if u change the mime type to text/html you can get the document.write output to work. however i am unsure of how i should do this. any help would be great
LukeakaDanish
Add an element where you wanted the document.write output to go, which looks like this:

Code:

<span id="anything"></span>


Then, in javascript included anywhere on the page do the following:

Code:

window.onload = function () { document.getElementById('anything').innerHTML = 'output'; }


This could also be achieved more dynamically using the DOM.

Its a little more complex that document.write, but much more flexible, and if you learning javascript, learning some basic DOM modification is essential anyway, so its not a problem that you have to spend some time learning it.

Hope that helped you!
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.