refering to a external JavaScript File in HTML

P

praveenmmohanan

Hi...,

I removed all the JavaScript code & put it in a file called abc.js from
a HTML page. Now I tried to refer it in the HTML page like this :

<script src="abc.js" type="text/javascript">
</script>

It gives me "Object Expected" error. Where should the abc.js reside in
the Web Project.

Regards,

Praveen
 
W

web.dev

Hi...,

I removed all the JavaScript code & put it in a file called abc.js from
a HTML page. Now I tried to refer it in the HTML page like this :

<script src="abc.js" type="text/javascript">
</script>

It gives me "Object Expected" error. Where should the abc.js reside in
the Web Project.

That depends on what your script does. Judging from your error
message, you're using IE. Using Firefox will give you better error
messages most of the time.

Was it working before you moved it to an external javascript file? If
so, then yes, it should be just a matter of placing it in the correct
location. Preferably in the same area where you removed your script.

If not, then you need to debug your script.
 
B

Bart Lateur

I removed all the JavaScript code & put it in a file called abc.js from
a HTML page. Now I tried to refer it in the HTML page like this :

<script src="abc.js" type="text/javascript">
</script>

It gives me "Object Expected" error. Where should the abc.js reside in
the Web Project.

The rules are the same as for other relative URLs -- for example images.
So, with no BASE tag specified: right next to the html file.

It sounds to me like the file (probably) is loaded, but something is
wrong in it. You won't get this kind of error message just because the
file isn't found.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top