Javascript src path...

Discussion in 'ASP .Net' started by JJ, Jul 11, 2006.

  1. JJ

    JJ Guest

    In my master page I am refering to a javascript source file:
    <script type="text/javascript" src="swfobject.js"></script>

    However, this src path will not be valid if any of my files using the master
    are in other directories...( as they are).

    How do specifiy the source file absolutely so it can be accessed from any
    location on the webserver ?

    JJ
     
    JJ, Jul 11, 2006
    #1
    1. Advertising

  2. JJ

    John Prado Guest

    This is an option, the easiest in my opinion:

    <script type="text/javascript"
    src='<%=ResolveUrl("~/swfobject.js")%>'></script>

    JJ wrote:
    > In my master page I am refering to a javascript source file:
    > <script type="text/javascript" src="swfobject.js"></script>
    >
    > However, this src path will not be valid if any of my files using the master
    > are in other directories...( as they are).
    >
    > How do specifiy the source file absolutely so it can be accessed from any
    > location on the webserver ?
    >
    > JJ
    >
    >
     
    John Prado, Jul 11, 2006
    #2
    1. Advertising

  3. JJ

    JJ Guest

    That helped a lot - thanks,
    JJ

    "John Prado" <> wrote in message
    news:...
    > This is an option, the easiest in my opinion:
    >
    > <script type="text/javascript"
    > src='<%=ResolveUrl("~/swfobject.js")%>'></script>
    >
    > JJ wrote:
    >> In my master page I am refering to a javascript source file:
    >> <script type="text/javascript" src="swfobject.js"></script>
    >>
    >> However, this src path will not be valid if any of my files using the
    >> master are in other directories...( as they are).
    >>
    >> How do specifiy the source file absolutely so it can be accessed from any
    >> location on the webserver ?
    >>
    >> JJ
    >>
     
    JJ, Jul 11, 2006
    #3
  4. U¿ytkownik "JJ" <> napisa³ w wiadomo¶ci
    news:...
    > In my master page I am refering to a javascript source file:
    > <script type="text/javascript" src="swfobject.js"></script>
    >
    > However, this src path will not be valid if any of my files using the
    > master are in other directories...( as they are).
    >
    > How do specifiy the source file absolutely so it can be accessed from any
    > location on the webserver ?


    John wrote one, and others are:
    src="/file.js"
    src="http://domain/file.js"


    --
    JS
    BRE Bank Dev Team, Poland
     
    Jacek Stawicki, Jul 11, 2006
    #4
  5. JJ

    John Prado Guest

    Jacek Stawicki wrote:
    > U¿ytkownik "JJ" <> napisa³ w wiadomo¶ci
    > news:...
    >> In my master page I am refering to a javascript source file:
    >> <script type="text/javascript" src="swfobject.js"></script>
    >>
    >> However, this src path will not be valid if any of my files using the
    >> master are in other directories...( as they are).
    >>
    >> How do specifiy the source file absolutely so it can be accessed from any
    >> location on the webserver ?

    >
    > John wrote one, and others are:
    > src="/file.js"
    > src="http://domain/file.js"
    >
    >


    This works too but in a develop environment with a server in root and a
    lot of other app in sub directories this could be a problem.

    With the ResolveUrl you can assigned the src of scripts in root of your
    app instead of root server.
     
    John Prado, Jul 11, 2006
    #5
  6. JJ

    JJ Guest

    Yes - in this case I am not sure what the final domain name will be, and it
    may well change.

    "John Prado" <> wrote in message
    news:%...
    > Jacek Stawicki wrote:
    >> U¿ytkownik "JJ" <> napisa³ w wiadomo¶ci
    >> news:...
    >>> In my master page I am refering to a javascript source file:
    >>> <script type="text/javascript" src="swfobject.js"></script>
    >>>
    >>> However, this src path will not be valid if any of my files using the
    >>> master are in other directories...( as they are).
    >>>
    >>> How do specifiy the source file absolutely so it can be accessed from
    >>> any location on the webserver ?

    >>
    >> John wrote one, and others are:
    >> src="/file.js"
    >> src="http://domain/file.js"
    >>
    >>

    >
    > This works too but in a develop environment with a server in root and a
    > lot of other app in sub directories this could be a problem.
    >
    > With the ResolveUrl you can assigned the src of scripts in root of your
    > app instead of root server.
     
    JJ, Jul 12, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter

    <txt src= ...> equivalent of <img src= ...>

    Steve Richter, Feb 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,104
    Laurent Bugnion
    Feb 9, 2006
  2. Greg Johnson
    Replies:
    4
    Views:
    3,084
  3. Replies:
    1
    Views:
    1,626
    Alex Hunsley
    Mar 23, 2007
  4. pheadxdll
    Replies:
    16
    Views:
    3,694
    Neredbojias
    Jun 6, 2007
  5. Soren Vejrum
    Replies:
    4
    Views:
    624
    Lasse Reichstein Nielsen
    Jul 5, 2003
Loading...

Share This Page