247 users online (0 members and 247 guests)  


  Results 1 to 4 of 4

Related

  1. need help with onclick link to external .JS file    Forum: Javascript Forum
    Replies: 0
  2. [SPLIT]passing values to an external .js file    Forum: Javascript Forum
    Replies: 37
  3. adding up my values    Forum: Javascript Forum
    Replies: 1
  4. Replies: 1
  5. passing values to an external .js file    Forum: Javascript Forum
    Replies: 10
  1. #1
    chriswick's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2007
    Posts
    2

    Arrow Adding values to an external .js Javascript file?

    I am trying to build a widget to the website I'm build. The only part I can seem to get working is this bit.

    Example Code:

    HTML Code:
    <SCRIPT language="JavaScript">
    bg_color = "#FFFFFF";
    </SCRIPT>
    <SCRIPT TYPE="text/javascript" SRC="http://www2.domainname.com/file/file.js"></SCRIPT>
    I just need to know what code I put in with the Javascript file to change the values over.

    Chris

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Adding values to an external .js Javascript file?

    Make your javascript a function and pass variable values as parameters.

    It would be helpful for you to give us a little more detail on what you're trying to do.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    chriswick's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2007
    Posts
    2

    Re: Adding values to an external .js Javascript file?

    I'm trying to change the background color on the contant that comes from out of the file.
    How would I code that? I made this but it dosn't work?
    function stamp(bg_color) {
    document.write("<body bgcolor= "+ bg_color + ", ");
    }

  4. #4
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Adding values to an external .js Javascript file?

    Change this statement:

    Code:
    document.write("<body bgcolor= "+ bg_color + ", ");
    to this:

    Code:
    document.write("<body bgcolor= "+ bg_color + "> ");
    You'll want to make sure you have an alternative for anyone with javascript disabled. You might want to look through the search results for style switcher for a better way of doing this.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more



Tags for this Thread