View Full Version : external js file

11-22-2007, 05:02 PM
how can i call/activate an external js-file in conditional case?
for example say;
if daynumber of today >10, i want js-file come into action.
i write it as follows, but not running

<script language="javascript" >
if (Daynumber>10) {src="archivLINES.js"}

(Daynumber is off course defined before)
i guess it is wrong with "scr="; what is then correct code-line?

i will be very gratefull for any help...

11-22-2007, 05:21 PM
Don't use the decapitated (deprecated) language attribute. You can just doc write it out.

<script type="text/javascript">
if (Daynumber>10)
document.write('<script type="text/javascript" src="archivLINES.js"><\/script>');

You could use the DOM, but that gets a bit complicated and isn't supported well for script tags.

A better approach would be to have your function that actually does the work check this, ex:

function archive_lines(){
if (Daynumber<11)
. . .

doing nothing if the value is less than 11.

11-23-2007, 07:11 AM
jscheuer1, many thanks for replay+effort+enlightening lines...