/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Script Src

i have a problem, i am trying to implement an html file that has javascript in it. here is what i have:

<SCRIPT TYPE=”text/JavaScript” SRC=”bundle.js”></SCRIPT>

the problem is that i need the value of the SRC attribute to be dynamic based on the locale of the browser. i thought this might work:

<SCRIPT TYPE=”text/JavaScript” SRC=navigator.browserLanguage+”bundle.js”></SCRIPT>

but it doesnt work. so im not sure how i can make it so the script loaded is from a directory that i dont know at coding time.

any help is greatly appreciated!!!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMar 24.2005 — [font=monospace]<script type="text/javascript">

<!--

document.write('<script src="', navigator.browserLanguage, 'bundle.js" type="text/javascript"></script>');

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@stl2smlauthorMar 24.2005 — great thanks for the quick reply - i ended up using a variation of this.

thanks again!
×

Success!

Help @stl2sml 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.18,
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,
)...