/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] attach a javascript file

Hi

Is it at all possible to have one page of javascript code which your pages refer to ( like a external stylesheet) …?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@thaKingJul 27.2006 — yes, it would be something like this:

<script language="JavaScript" type="text/javascript" src="swap.js"></script>
Copy linkTweet thisAlerts:
@Noodle7authorJul 27.2006 — thanks will try that out ...this site rocks I have only been on it a few hours and all my questions have been answered!
Copy linkTweet thisAlerts:
@Noodle7authorJul 27.2006 — <script language="JavaScript" type="text/javascript" src="swap.js"></script>

so this goes where ? I have made a seperate js file and added it in but nothing happens .
Copy linkTweet thisAlerts:
@thaKingJul 27.2006 — it goes inside your <head></head> tags...
Copy linkTweet thisAlerts:
@Noodle7authorJul 27.2006 — <script type="text/javascript">

var arr=['100000','100001','1000002']//possible values

function goto(v) {

for(var i=0;i<arr.length;i++){

if(v==arr[i]){

location.href='http://www.africanmob.com/'+v+'.htm';

return;

}

}

alert('This page does not exist!')

}

</script>





I saved the above in a .js file called dealer



The below is what is iin the body of the page

<form>

<span style="cursor:pointer" onclick="goto(document.getElementById('url').value)" class="style31">

<input name="Input" type="text" id="url" size="5">

Go to Dealer </span>

</form>



and your code <script language="JavaScript" type="text/javascript" src="dealer.js"></script> goes in the header ? this ain't working any ideas?
Copy linkTweet thisAlerts:
@thaKingJul 27.2006 — your javascript page does not need the <script></script> in it...that only goes in the html page...remove those from your javascript file, save it and in your head tags put

<script language="JavaScript" type="text/javascript" src="dealer.js"></script>
Copy linkTweet thisAlerts:
@Noodle7authorJul 27.2006 — yipeee thanks its working like a dream..., ok last question is there away of clearing the input box once a user has entered a number?
×

Success!

Help @Noodle7 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.26,
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,
)...