I sure could use:
document.write('<br>');
or similar for text output, but this seems to create a new document, not append to the existing one. I don't fully understand why. I read it's because of some timing issue. In any case, I don't know how to display other stuff together with document.write()
I currently use:
Code:
function makeButton()
{ myParagraph = document.getElementById("paragraph1");
myButton = document.createElement("button");
buttonText1 = document.createTextNode("button In Form");
myButton.appendChild(buttonText1);
myButton.onclick = myOnClick;
myParagraph.appendChild(myButton);
}
....
<body>
<p id="paragraph1">
</p>
etc.
and am wondering what are convenient ways of writing text.
Thanks.
using the create element is the prefered way to do it as most other methods are being phased out by W3C as far as I know. Also with document.write() you ahve .open() and .close. although you could just use .innerHTML = "but this is being phased out too i think";
innerHTML is useful and in some case much less complicated. All the major browsers support it. W3C hasn't yet adopted it but I doubt the browsers will ever stop supporting it.
It's like the whole html is dead thing. Who is going to be the first to build a browser that doesn't support html?
yeah, I'm aware of potential problems... But the thing is I'm having a larger amount of repeatable code that requires dynamic changes. And there is a mini data base for which I need javascript. I don't think it can be done in html. Javascript is the only other web tool that I know (or rather am trying to learn).
In the meantime, I'll try to have an alternative page with limited functionality (as nice as reasonable) for browsers not supporting/disabled javascript.
i have run into problems with using innerHTML on firefox (very limited problems there). and bigger problems on safari. Usually works fine though, but doesn't really created the elements properly. For just throwing some text in, it's probably the best method at the moment due to lines of code.
another problem with dynamic text other than people with js disabled....search engine spiders don't see it either.
Bookmarks