/    Sign up×
Community /Pin to ProfileBookmark

switching .js files dynamically

Hey everybody – new here. I was wondering if anybody could tell me if it’s possible to set up a javascript that can choose which .js external file to load for a given page based on a query string in the URL?

I already have the function that strips the data out of the string. I just need to know if you can choose between .js files.

TIA!

j

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@NatdripAug 11.2006 — yes request a query string and then using a SSL write to the page.

here is an asp example.

<head>

<%

dim bob: bob = request.querystring("bob")

if bob<>"" then

response.write "<javascript1>"

else

response.write "<javascript2>"

end if

%>

</head>
Copy linkTweet thisAlerts:
@jenny091485authorAug 15.2006 — Great. (SSL means ? Server-side something, right?)

Anyway, let's assume for the sake of our little project that we can't use anything like ASP. Like, for instance, if our client wants to run this thing off a CD-R.

That means that everything has to be executable by a browser. Any ideas?
Copy linkTweet thisAlerts:
@dknight3Aug 15.2006 — <script type="text/javascript">

function includescript(sourcefile){

var scriptNode = document.createElement('script');

scriptNode.type = 'text/javascript';

scriptNode.src = sourcefile;

document.getElementsByTagName("head")[0].appendChild(scriptNode);

}

onload=function(){includescript(whatever the script name is)}

</script>
Copy linkTweet thisAlerts:
@jenny091485authorAug 16.2006 — Thanks! I'll try it.
×

Success!

Help @jenny091485 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...