Jump to content

document.write workaround help


chazzledazzle

Recommended Posts

Hello all,I am very new to JavaScript, and I am trying to get a page to include today's date, as well as a countdown to a specific date. For today's date, I am using:

<script language = "javascript" type="text/javascript"><!--today = new DateweekDayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")monthName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December")function printDate(){document.write("<b>" + weekDayName[today.getDay()]+ ", " + monthName[today.getMonth()] + " " + today.getDate()+ "</b>")}--></script>

The problem is that I am using a WYSIWYG editor that does not like the 'document.write' script. It says that 'if I do not remove the offending code (their words), then IE will crash.' :) As a workaround, I am trying to put the code into a js doc, and call it up with a <div> tag, as instructed by the tech help, but it isn't working. Does anyone know how to do this? I might have left out pertinent pieces. Any and all help is truly, truly appreciated. Thanks! :)

Link to comment
Share on other sites

You might try the HTML DOM to do this:

<div id="dateDisplay" /><script language="javascript" type="text/javascript"><!--	var today = new Date();	var weekDayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");	var monthName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");function printDate(){	var obj = document.getElementById("dateDisplay");	obj.innerHTML = weekDayName[today.getDay()]+ ", " + monthName[today.getMonth()] + " " + today.getDate();}--></script>

Link to comment
Share on other sites

Jesh,Thanks for your reply. Unfortunately, the editor doesn't recognize it, and there is no output. Sad. :) What I am going to have to figure out is:1. The exact script to put into the js doc.2. The div call, which i think i have.3. How to make this easier in the future.Here is the issue I am working with:I am using (read 'have to use') a web based WYSIWYG editor, that essentially breaks a page up into components...

  • there is a wrapper that contains the navigation pieces.
  • There is a WYSIWYG editor which inserts the pages into the wrapper.
  • In order to get any js into the pages, I need to do a call to the js doc.

I am not the most skilled programmer, so this is a bit of a challenge for me. Just starting out with O'Reilly's JavaScript book (not the 5th edition either, sadly). :)

Link to comment
Share on other sites

Jesh,Thanks for your reply. Unfortunately, the editor doesn't recognize it, and there is no output. Sad. :) What I am going to have to figure out is:1. The exact script to put into the js doc.2. The div call, which i think i have.3. How to make this easier in the future.Here is the issue I am working with:I am using (read 'have to use') a web based WYSIWYG editor, that essentially breaks a page up into components...
  • there is a wrapper that contains the navigation pieces.
  • There is a WYSIWYG editor which inserts the pages into the wrapper.
  • In order to get any js into the pages, I need to do a call to the js doc.

I am not the most skilled programmer, so this is a bit of a challenge for me. Just starting out with O'Reilly's JavaScript book (not the 5th edition either, sadly). :)

The post above your post is using the innerHTML feature. which all the data is sent to the div ID. in the html page, simply have a div with the id= whatever the id was. and all the data should be displayed there.ps. how does the editer not recognize javascript DOM?
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...