customising external .js files

M

mark | r

can you use asp to customise external js files e.g.

<script src="fred.js"></script>

where fred gets the page id and changes an image in the .js file to suit?

mark
 
T

Tom B

What I would do, is have a function in fred.js that accepts a parameter

For example in fred.js

function Start(aString)
{
alert(aString);
}

then in your "asp" code...

<%
Dim sString
sString="'Hello'"
%>

<script src="fred.js"></script>
<script language=Javascript>
Start(<%=sString%>)
</script>

which would result in
<script src="fred.js"></script>
<script language=Javascript>
Start('Hello')
</script>
 
R

Ray at

<script src="fred.ASP">

Use that, and then in fred.asp, response.write your client-side code as
needed.

Ray at work
 
C

Chris Barber

I suppose you could ask ... why? If it's dynamic then what's the point of it
being a src="" since there is no point in caching it.

Generalise your scripts enough to be cacheable and then put the dynamic
stuff direct into the html page?

Do you have a specific aim in mind for this since it's not clear what the
context or final intention is?

Chris.


wjat i mean is can the contents of a .js file be built?

mark
 
D

Dave Anderson

Chris Barber said:
I suppose you could ask ... why? If it's dynamic then what's
the point of it being a src="" since there is no point in
caching it.

One reason comes to mind. I believe it has been explored in
ms.public.scripting.jscript as a means for hiding source code from prying
eyes. I don't recall the consensus on its effectiveness, however.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top