Results 1 to 3 of 3

Thread: external js file

  1. #1
    Join Date
    Nov 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default external js file

    hi
    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"}
    }
    </script>


    (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...

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Don't use the decapitated (deprecated) language attribute. You can just doc write it out.

    Code:
    <script type="text/javascript">
    if (Daynumber>10)
    document.write('<script type="text/javascript" src="archivLINES.js"><\/script>');
    </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:

    Code:
    function archive_lines(){
    if (Daynumber<11)
    return;
     . . .
    doing nothing if the value is less than 11.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1, many thanks for replay+effort+enlightening lines...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •