/    Sign up×
Community /Pin to ProfileBookmark

problem with <script> tag!!

hi all:
something weird is happening with the <script> tag. I simple have on my page a button that calls a function which also calls another function that is in a .js file, the problem arises when I write the language and src properties, the browser sends an error and the only way to fix it is deleting the properties and leaving the <script> tag alone, but I can`t use the .js file….any idea what’s going on????
thx

this is the code:
<html>
<head>

<SCRIPT LANGUAGE=’JavaScript’ SRC=’caca.js’ >
function koko(){
alert(“hace koko”);
var d = newArray(“dvsd”,”fs”)
o (d)//this function is in caca.js
};

</script>
</head>

<body>
<input type=”button” onClick=”koko();” value=”Check your work” >

</body>
</html>

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzFeb 27.2006 — When you specify the src attribute on a script element, the contents of that element is ignored. You should use two script elements instead or move the code from inside the script element to the .js file.
Copy linkTweet thisAlerts:
@moshlpauthorFeb 27.2006 — but this is so simple, i just wanna call an external .js and I get an error. I've checked posts and the <script> tags are exactly the same as mine. Am I missing something?

by using different script, you mean: <script language='javascript'> <script src='caca.js'> ?does it work?

the idea of using the js file is that the functions in the file are shared by many webpages, and the new info is the one sent to those functions in the array d.
Copy linkTweet thisAlerts:
@James_GatkaFeb 27.2006 — When including a .js file, you need a closing script tag:

[CODE]<html>
<head>
<SCRIPT type="text/javascript" SRC='caca.js' ></script>

<script type="text/javascript">
function koko(){
alert("hace koko");
var d = newArray("dvsd","fs")
o (d)//this function is in caca.js
}
</script>

</head>

<body>
<input type="button" onclick="koko()" value="Check your work" >

</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@KravvitzFeb 27.2006 — You're also missing a space between 'new' and 'Array'.

Try this:
&lt;script type='text/javascript' src='caca.js'&gt;&lt;/script&gt;
&lt;script type='text/javascript'&gt;
function koko(){
alert("hace koko");
var d = new Array("dvsd","fs")
o (d)//this function is in caca.js
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@AltF4Feb 28.2006 — Yah what they say is correct. The browser is confused wether to use the external or the script on the page.

Good Luck!





[SIZE=2]Go to www.davidlemcoe.com[/SIZE]
Copy linkTweet thisAlerts:
@moshlpauthorFeb 28.2006 — thanx mate!! got it now
×

Success!

Help @moshlp 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.16,
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,
)...