SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Say I have a tag like this

    <SCRIPT src="navbar.js?width=580"></SCRIPT>

    This is just a very simplified example.

    In my navbar.js file, how would I retrieve the arguments such as "width"?

    ie

    var width = /*?????*/;
    document.write("<TABLE width="+width+">");


    Thanks,

  2. #2
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    What you could do is define width in the HTML page:

    width="whateveR";
    <SCRIPT src="navbar.js"></SCRIPT>

    aDog

  3. #3
    SitePoint Member
    Join Date
    Dec 2000
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't remember if JavaScript has any support for QueryStrings (a QueryString is the width=580 part), but if you want you could use regular expressions to rip it out of the pathname. Let me know if you would like me to elaborate any more, and if I figure out if JS supports a QueryString then I will write you back :-)

  4. #4
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, I've figured it out now.

    In fact it is more like this:

    <script language="javascript" src="navbar.js"></SCRIPT>
    <script language="javascript">
    <!--
    insertnavbar(580);
    //-->
    </SCRIPT>

    I define the function in navbar.js but do not call it yet, so I can call it from the page

    This will do until I get a host that supports SSI.


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
  •