Jump to content

document.write problem


Err

Recommended Posts

hey all.I have this calendar that I've created in JavaScript that has no formatting. I use document.write to display the all the elements for the calendar but I've recently come across a problem when trying to use document.write in a function.So, I have put my calendar making script into a function, move the script into the <head> of the document and make a button with an onclick event to call my function. Everything works great until I click on the button to call my script, when the script makes the calendar it takes off the text which explains what the script does. Basically it removes any HTML on the page and places the JavaScript generated calendar. Also it looks like my browser is still trying to load something, I can stop the loading if I refresh the page. Any one know a way around this? I've tried using innerHTML, but I can only display one thing at a time for an element. I need to display the entire calendar without either of those things happening.

Link to comment
Share on other sites

What is wrong with using innerHTML? You can have one giant division to hold your generated calendar, and replace all document.write statements with

document.getElementById('calendar').innerHTML += "whatever used to be in document.write()";

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...