Syntax Error 'SCRIPT1002' using Internet Explorer 11

13,047

Solution 1

The problem probably resides in your dashboard.js file. On line 4 you have a setInterval():

var id = setInterval(frame, speed, );

There is either a parameter missing or you accidentally added an extra comma.

To reproduce this you can include the dashboard.js file on any page and the syntax error will be displayed.

Solution 2

If you are using arrow syntax like value.foreach(param => {}); It can also cause this error in IE 11 since it does not understand shorthand functions. Need to change the function to be: value.foreach(function(param){});

Share:
13,047
Erleiuat
Author by

Erleiuat

Updated on July 27, 2022

Comments

  • Erleiuat
    Erleiuat almost 2 years

    SCRIPT1002: Syntax error index.php, line 4 character 37

    I got this error in IE11 and my .click() handlers are not working on the page where the error occurs (only in IE11). On lines 1 to 10 I got some standart meta tags so that shouldn't be the problem (I removed them and still received the error).

    Because I got a lot of code and I don't know where exactly this error occurs. What's the best way to find the responsible code for this error?

    Here is the index.php file referenced in the error:

    <!DOCTYPE html>
    <html lang="en">
    
        <?php
            include("database/connect.php");
            include("modul/session/session.php");
            $sql = "SELECT * FROM `tb_appinfo`;";
            $result = $mysqli->query($sql);
            if (isset($result) && $result->num_rows == 1) {
                $appinfo = $result->fetch_assoc();
            }
            $sql = "SELECT * FROM `tb_ind_design` WHERE tb_user_ID = $session_userid;";
            $result = $mysqli->query($sql);
            if (isset($result) && $result->num_rows == 1) {
                $row = $result->fetch_assoc();
            }
        ?>
    
        <head>
    
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            <meta name="description" content="<?php echo $appinfo["description"];?>">
            <meta name="author" content="A.Person">
    
            <title><?php echo $appinfo["title"];?></title>
    
            <!-- Bootstrap core CSS -->
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    
            <!-- Custom styles for this template -->
            <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    
            <?php
                if (preg_match("/(Trident\/(\d{2,}|7|8|9)(.*)rv:(\d{2,}))|(MSIE\ (\d{2,}|8|9)(.*)Tablet\ PC)|(Trident\/(\d{2,}|7|8|9))/", $_SERVER["HTTP_USER_AGENT"], $match) != 0) {
                    echo '<link href="css/evaStyles_ie.css" rel="stylesheet">';
                } else {
                    if(isset($row)){
                        echo '
                        <meta name="theme-color" content="'.$row["akzentfarbe"].'"/>
                        <style>
                            :root {
                                --hintergrund: '.$row["hintergrund"].';
                                --akzentfarbe: '.$row["akzentfarbe"].';
                                --schrift: '.$row["schrift"].';
                                --link: '.$row["link"].';
                            }
                            html {
                                --hintergrund: '.$row["hintergrund"].';
                                --akzentfarbe: '.$row["akzentfarbe"].';
                                --schrift: '.$row["schrift"].';
                                --link: '.$row["link"].';
                            }
                        </style>
                        <link href="css/evaStyles.css" rel="stylesheet">
                        ';
                    } else {
                        echo '
                        <meta name="theme-color" content="'.$appinfo["akzentfarbe"].'"/>
                        <style>
                            :root {
                                --hintergrund: '.$appinfo["hintergrund"].';
                                --akzentfarbe: '.$appinfo["akzentfarbe"].';
                                --schrift: '.$appinfo["schrift"].';
                                --link: '.$appinfo["link"].';
                            }
                            html {
                                --hintergrund: '.$appinfo["hintergrund"].';
                                --akzentfarbe: '.$appinfo["akzentfarbe"].';
                                --schrift: '.$appinfo["schrift"].';
                                --link: '.$appinfo["link"].';
                            }
                        </style>
                        <link href="css/evaStyles.css" rel="stylesheet">
                        ';
                    }
                }
            ?>
    
        </head>
    
    
        <body>
            <div class="loadScreen">
                <span class="helper"></span><img class="img-responsive" id="loadingImg" src="img/loading.svg"/>
            </div>
    
            <div id="pageContents" style="opacity: 0;">
    
                <!-- Navigation -->
                <div id="naviLink">
                    <nav class="navbar navbar-expand-lg navbar-inverse bg-color fixed-top" id="slideMe" style="display: none;">
                        <div class="container">
                            <a class="navbar-brand" href="modul/dashboard/dashboard.php">
                                <img src="<?php echo $appinfo["logo_path"];?>" width="<?php echo $appinfo["logo_width"];?>" alt="Logo">
                                <span style="margin-left:20px;"><?php echo $appinfo["title"];?></span>
                            </a>
                            <button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                                <span class="navbar-toggler-icon"></span>
                            </button>
                            <div class="collapse navbar-collapse" id="navbarResponsive">
                                <ul class="navbar-nav ml-auto">
    
                                    <?php
                                        $userID = ($mysqli->query("SELECT ID FROM tb_user WHERE bKey = '$session_username'")->fetch_assoc());
                                        $sql1 = "SELECT mg.ID, mm.file_path, mm.title FROM tb_ind_nav AS mg INNER JOIN tb_modul AS mm ON mm.ID = mg.tb_modul_ID WHERE mg.tb_user_ID = " . $userID['ID'] . " ORDER BY mg.position";
                                        $result = $mysqli->query($sql1);
                                        if (isset($result) && $result->num_rows > 0) {
                                            while($row = $result->fetch_assoc()) {
                                                $link = '
                                                <li class="nav-item">
                                                    <a class="nav-link" navLinkId="'. $row["ID"].'" href="'. $row["file_path"].'">'. $translate[$row["title"]].'</a>
                                                    </li>
                                                    ';
                                                    echo $link;
                                            }
                                        } else {
                                            $link = '
                                            <li class="nav-item" id="editNavLink">
                                                <a class="nav-link" href="modul/settings/settings.php">'. $translate[15].'</a>
                                            </li>
                                            ';
                                            echo $link;
                                        }
                                    ?>
    
                                </ul>
                            </div>
                        </div>
                    </nav>
                </div>
    
                <!-- Page Content -->
                <div class="container">
                    <div class="row">
                        <div class="col-lg-10 offset-md-1">
                            <div page="<?php if(isset($_SESSION["user"]["currentPath"])){ echo $_SESSION["user"]["currentPath"]; } else { echo "modul/dashboard/dashboard.php";} ?>" id="pageContent">
    
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.container -->
    
                <footer class="footer" id="slideMeFoot" style="display: none;">
                    <div class="container">
                        <a class="foot-link" href="modul/settings/settings.php"><?php echo $translate[16] ?></a><i class="text-muted"> | <?php echo $_SESSION["user"]['username']; ?></i><span class="text-muted">©<a href="https://your-website.ch"> HTML Link</a> | 2018 | <?php echo $appinfo["title"];?> <a href="https://github.com/link-to/repo">v.1.0</a></span>
                    </div>
                </footer>
            </div>
    
            <!-- Bootstrap core JavaScript -->
            <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
    
            <!-- Own JS -->
            <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment.min.js"></script>
    
            <script type="text/javascript">
                var translate = {};
                <?php
                    foreach ($translate as $key => $value) {
                        echo ("translate['".$key."'] = '".$value."';");
                    };
                ?>;
            </script>
            <script src="js/index.js"></script>
    
        </body>
    
    </html>
    
    • Turnip
      Turnip about 6 years
      The error tells you exactly which line of code is causing the problem.
    • Admin
      Admin about 6 years
      Well there's not any script on this line. Or am I searching in the wrong file?
    • Turnip
      Turnip about 6 years
      What is on line 4 of the rendered html? (Right click > View source)
    • freedomn-m
      freedomn-m about 6 years
      The error is shown in the browser, so it relates to the rendered html, not the original source.
    • Admin
      Admin about 6 years
      @Turnip #This Meta-Tag: <meta charset="utf-8">
    • freedomn-m
      freedomn-m about 6 years
      Of course, it's IE, so don't expect it to get the line number right - check 3-4 lines either side of that as well...
    • freedomn-m
      freedomn-m about 6 years
      The best way to find the error is to keep remove lines until it stops coming up. (or remove all the lines then add them back in... your choice). You can do this one at a time or a few at a time - eg remove 10 it stops so add them back and remove 5 - until you narrow it down to the offending line.
    • Admin
      Admin about 6 years
      @freedomn-m Just added the first lines of the rendered html (See Edit)
    • Turnip
      Turnip about 6 years
      ^ this. I'd remove whole blocks of PHP one at a time and then individual JS files until the problem disappears. Then you know where to look.
    • Admin
      Admin about 6 years
      @freedomn-m I already tried to remove all meta tags and almost everything I found in the head section. But the error still appeard
    • CBroe
      CBroe about 6 years
      The only inline script element is the one where you fill your translate variable, so go check the output in that place, whether that looks correct. (Btw., heard of JSON?) If that’s not it, then the error is most likely in your js/index.js file.
    • freedomn-m
      freedomn-m about 6 years
      If error still appeared after removing stuff in the head - then the error is not in the head. Unfortunately IE isn't the best at telling you where the error actually is - do you get the same problem in Chrome?
    • Admin
      Admin about 6 years
      @CBroe I removed the whole script and still got the same error. I also tried to remove every function in js/index.js and test it again, but every time I received the error. (Yes, heard about JSON, but excuse my laziness :-) (Work in progress))
    • Admin
      Admin about 6 years
      @freedomn-m Everything is working fine in Chrome and Firefox.
  • dilettante
    dilettante almost 5 years
    Yes, IE11 doesn't support promises, and there's no great way around the issue.
  • ndreisg
    ndreisg over 3 years
    @dilettante the way around this issue would be to use a polyfill, for example Bluebird.js