www.webdeveloper.com
Results 1 to 11 of 11

Thread: Unexpected token?

  1. #1
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    76

    Unexpected token?

    When i am running a certain script ... I get "Uncaught SyntaxError: Unexpected token } eartraining.html:2" in the Chrome in the developer tools frame. the problem is it says the unexpected token is located in the html document and it refers me to the beginning of the document, before any of my external scripts are even loaded. HUH???

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354
    Could be anything from the information given.
    Do you have some sample code or a link to an active site?

  3. #3
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    76
    melodicpulse.webs.com/eartraining.html when you click on 'triad test' or 'seventh chord test' there is a quiz that pops up, then when you click on 'play sound' there is supposed to be a random sound file that plays, but instead I get that error message in the elements tab of the developer tools
    Last edited by thewebiphyer; 02-11-2013 at 11:14 AM.

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354
    Looking at their code for the 'chdcheck()' function, it appears they expect at least 3 arguments.
    However in the calling code, they are sending only two.

    Probably the source of the fatal error.
    Also, there are numerous CSS warnings (not fatal)

    Have you contacted the authors if this is not your own?

  5. #5
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    76
    no this is all my code... sending two arguments? wow how did I not see that.. thanks I'll make some adjustments and hopefull that will work.

  6. #6
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354

    Arrow

    Quote Originally Posted by thewebiphyer View Post
    no this is all my code... sending two arguments?
    wow how did I not see that..
    thanks I'll make some adjustments and hopefull that will work.
    Well my professions is an optometrist.
    I help people see what they cannot!

    Good Hunting and Good Luck!

  7. #7
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    76
    well I fixed the argument issue and it's still telling me there's an unexpected token in HTML document. I still don't understand why it would say there's a script error in an HTML document. Either way I did look through the rest of the code and could not find anything that may be causing it.

  8. #8
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354

    Arrow

    Quote Originally Posted by thewebiphyer View Post
    well I fixed the argument issue and it's still telling me there's an unexpected token in HTML document. I still don't understand why it would say there's a script error in an HTML document. Either way I did look through the rest of the code and could not find anything that may be causing it.
    It may not be in the HTML document. It holds the call to the external JS source file and that is where I think the problem is.
    It reports the error being found in the HTML.

    One other thing to check.
    Code:
    //-------------------------GENERATE CHORD QUIZ --------------------
    function chd_quiz(type) {
        if (document.getElementById('sound1').innerHTML == ""){
            s=1; trys = 1; score = 0; counter = 1;
            while (s < 21){
                document.getElementById("sound"+s).innerHTML="<input \
            type='button' onclick='change_chdsource("+s+","+s+",'"+type+"')' value='Play Chord' \
            id=\""+s+"\" /><form id=''><input type='text' id='ui"+s+"' /><br><br>\
    
    .....
    
    //-----------------------generate random chord sound -----------
    function change_chdsource(ques_num,buttonid,type) {
    //------------------------first click ---------------
        if (counter==1){
            if(type=="tri"){
                var chdtype="tri", select_qual=chdfolder('tri'); select_file = find();       
            }
            else if(type=="sev"){
                var chdtype="sev", select_qual=chdfolder('sev'); select_file = find();
            }
    'type' is a reserved word in HTML and maybe JS.
    You might try changing it to something else. A bit more descriptive as to its function maybe.

    I don't know if that will fix it, but it's a start.
    Check the error console if using FF or Chrome browsers for a report on fatal and non-fatal errors.

  9. #9
    Join Date
    Oct 2011
    Location
    Hamilton, Ontario
    Posts
    76
    well I'm not familiar with FF but i did try changing the 'type' variable and it still didn't do much... still trying to figure this out, but no luck yet. i did notice in FF it told me there was no character encoding declared but isn't that what the <!DOCTYPE html> tag does?
    Last edited by thewebiphyer; 02-13-2013 at 12:53 PM.

  10. #10
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354
    Quote Originally Posted by thewebiphyer View Post
    ...
    i did notice in FF it told me there was no character encoding declared but isn't that what the <!DOCTYPE html> tag does?
    No, you need something similar to this:
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    charset can have other values.

  11. #11
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,354
    Quote Originally Posted by thewebiphyer View Post
    ...
    i did notice in FF it told me there was no character encoding declared but isn't that what the <!DOCTYPE html> tag does?
    No, you need something similar to this:
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    charset can have other values.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles