error while giving src for <script> tag

ambergarg22

New Member
Messages
19
Reaction score
0
Points
0
in my javascript i have a script tag which works fine.But the moment i mention a src to the script tag , it gives an error

eg. <script language="javascript" src="audio-player.js">

I have audio-player.js file uploaded in the same folder as the source HTML file.The error msg is "object expected"

Plz help
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Do you have an URL where we can see this problem?
 

ambergarg22

New Member
Messages
19
Reaction score
0
Points
0
the URL is http://www.ambergarg.x10.mx/audio-plag1.html

If u view the source code at line 31 u will see the <script> tag with src attribute.Although the error comes on the line where this function is called i think its due to src attribute.

Now if u remove the src attribute , there is no error and the output is also displayed on the website
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
"object expected" indicates that the script is loading and trying to access an undefined value. We'll need to see some code, a minimal test case. We'll also need a link to a live page for the minimal test case and an indication of which line is generating the error (mark it with a comment). Note that IE doesn't give correct line numbers; you'll need to use Firefox, Safari or some other, better browser.

One thing you can do to help yourself (besides producing a minimal test case) is to use an interactive debugger, such as Firebug ([2], [3]; note: Firebug is a Firefox extension) to examine the values of the variables in the problematic statement and figure out why it's generating an error.
 
Last edited:

ambergarg22

New Member
Messages
19
Reaction score
0
Points
0
Actually the code was too long to be posted here and it will be cumbersome for ppl to look into so i thought it will be easier for ppl to Right click on the page and click "VIEW SOURCE" option and open in any editor and look on line 31 where my script tage begins.

As for firefox is concerned , I dont hv permission on this computer to use that so i will have to be content with IE :( .How i identified the error in src attribute was the fact that the moment i remove the src attribute there is no error and the output is displayed for the webpage.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Actually the code was too long to be posted here and it will be cumbersome for ppl to look into
If it's too cumbersome to post, it's likely too cumbersome to look through on a live page, which is why I said to create a minimal test case. Read my sig.

As for firefox is concerned , I dont hv permission on this computer to use that so i will have to be content with IE
IE8 (if that's what you're using) has its own debugger. From what I recall, you don't need to install it.

As for the linked page, the only error it generates is a 404 for the non-existent favicon.
 
Last edited:

ambergarg22

New Member
Messages
19
Reaction score
0
Points
0
I got the solution now.Thanks every1 who spent their time on this post. Actually there should have been 2 script tags , one for external js file and one for the functions defined in the source file.Its working fine now :)
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Do you mean you were doing something like the following?

HTML:
<script src="foo.js">
  function bar() { alert("foobar"); }
</script>

From the specification for the <source> element:
The script may be defined within the contents of the SCRIPT element or in an external file. If the src attribute is not set, user agents must interpret the contents of the element as the script. If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI.
 

ambergarg22

New Member
Messages
19
Reaction score
0
Points
0
@misson : yeah exactly , i didnt observed it till 5 hrs.But better late than never :)
 
Top