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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top