Javascript src path...

  • Thread starter Thread starter JJ
  • Start date Start date
J

JJ

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
 
This is an option, the easiest in my opinion:

<script type="text/javascript"
src='<%=ResolveUrl("~/swfobject.js")%>'></script>
 
That helped a lot - thanks,
JJ

John Prado said:
This is an option, the easiest in my opinion:

<script type="text/javascript"
src='<%=ResolveUrl("~/swfobject.js")%>'></script>
 
U¿ytkownik "JJ said:
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"
 
Jacek said:
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.
 
Back
Top