PDA

View Full Version : call an external script in the body


quartzy
05-08-2009, 05:35 PM
I need to call an external script, to where I want it in the body of the XHTML. I have tried this
<code>
<div class="bar">
<h2 class="digitalclock"><span>About Us</span>
<script type="text/javascript">
/* <![CDATA[ */
document.write('<script src="', js/date.js, '" type="text/JavaScript"><\/script>');
/* ]]> */
</script>
</h2><noscript><p>Scripts disabled - Date and Time clock</p></noscript></div>
</code>
but it does not work, so wondered if there was an event handler I could use. The problem I have is that it is a date script that I only want on the bar so if I link to the script in the head, I still need to call it somehow. Can anyone help, I am new to all this javascript an EH and DOM

abduraooft
05-08-2009, 05:59 PM
<h2 class="digitalclock"><span>About Us</span>
<script src="js/date.js" type="text/javascript"></script>
<noscript><p>Scripts disabled - Date and Time clock</p></noscript>?

quartzy
05-08-2009, 06:36 PM
thanks for that, tried it before and it did not work, so tried it again and it now works.

quartzy
05-08-2009, 06:55 PM
I have this date script and I cant get rid of the date word. Do you know how I can do this? If I remove the date word from the code the script does not work.
<code>
cDate = new Date();
document.write("Date:" + cDate.toLocaleString());
</code>

rnd me
05-09-2009, 09:00 AM
I have this date script and I cant get rid of the date word. Do you know how I can do this? If I remove the date word from the code the script does not work.
<code>
cDate = new Date();
document.write("Date:" + cDate.toLocaleString());
</code>

i don't know why it would matter, but if the above is true, you could likely coax the same beahvior with an empty or space string instead of "date:".

document.write( " " + cDate.toLocaleString());

quartzy
05-09-2009, 03:07 PM
Hello
Yes, I could not figure out why it mattered, it just did, I will try it your way, or look for another script. Thanks