Javascript src path...

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
 
J

John Prado

This is an option, the easiest in my opinion:

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

JJ

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>
 
J

Jacek Stawicki

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"
 
J

John Prado

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.
 
J

JJ

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

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top