最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

methods - I got the Expected SCRIPT1005: '(' with JavaScript on Edge, with Chrome it's working fine, why

programmeradmin1浏览0评论

I resolve a problem which was showing up no patibility on Edge but in Chrome. So, I changed using Object.assign(a, {}) instead of {...a, {}}.

Here's where I discussed this previous problem: I would like to know why my website is not showing up on Edge? it's developed on JavaScript

But, later I got another error. And let me explain you. It's this one on the console: SCRIPT1005: Expected '('. This error appears just on Edge browser.

main.load = function (page) {
    function getClass(className) {
        return Function('return ' + className)();
    }

    return new Promise((resolve, reject) => {
        try{
            new getClass(page); 
        }catch{ // Here's the: SCRIPT1005: SCRIPT1005: Expected '('; error.
            var count = 0;
            let script = dom("script",document.createElement("div"));
            script.src = `src/pages/${page}/${page}.js`;

            document.body.appendChild(script);
            return;
        }
        resolve(getClass(page));
    });
}```

I'm trying to look for a way to change some promises and try and catch that are wrapping the line the error is telling me on the console that is wrong.

```try{javascript
            new getClass(page); 
        }catch{ // Here's the: SCRIPT1005: SCRIPT1005: Expected '('; error.
            var count = 0;
            let script = dom("script",document.createElement("div"));
            script.src = `src/pages/${page}/${page}.js`;

            document.body.appendChild(script);
            return;
        }```

SCRIPT1005: Expected '('

I resolve a problem which was showing up no patibility on Edge but in Chrome. So, I changed using Object.assign(a, {}) instead of {...a, {}}.

Here's where I discussed this previous problem: I would like to know why my website is not showing up on Edge? it's developed on JavaScript

But, later I got another error. And let me explain you. It's this one on the console: SCRIPT1005: Expected '('. This error appears just on Edge browser.

main.load = function (page) {
    function getClass(className) {
        return Function('return ' + className)();
    }

    return new Promise((resolve, reject) => {
        try{
            new getClass(page); 
        }catch{ // Here's the: SCRIPT1005: SCRIPT1005: Expected '('; error.
            var count = 0;
            let script = dom("script",document.createElement("div"));
            script.src = `src/pages/${page}/${page}.js`;

            document.body.appendChild(script);
            return;
        }
        resolve(getClass(page));
    });
}```

I'm trying to look for a way to change some promises and try and catch that are wrapping the line the error is telling me on the console that is wrong.

```try{javascript
            new getClass(page); 
        }catch{ // Here's the: SCRIPT1005: SCRIPT1005: Expected '('; error.
            var count = 0;
            let script = dom("script",document.createElement("div"));
            script.src = `src/pages/${page}/${page}.js`;

            document.body.appendChild(script);
            return;
        }```

SCRIPT1005: Expected '('
Share Improve this question asked Jun 6, 2019 at 14:21 Reyo-mander of Jesus ChristReyo-mander of Jesus Christ 3373 silver badges11 bronze badges 5
  • 3 } catch (error) { – sp00m Commented Jun 6, 2019 at 14:23
  • Thank you it worked!, but why is mandatory to use the error reserved word? – Reyo-mander of Jesus Christ Commented Jun 6, 2019 at 15:22
  • error isn't reserved here, it's just a parameter name (i.e. you can rename it e or foobar). What's mandatory is to have a single parameter for the catch block (will hold the error that got thrown). – sp00m Commented Jun 6, 2019 at 15:25
  • developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – sp00m Commented Jun 6, 2019 at 15:29
  • So is this issue because Microsoft Edge is being strict about the Javascript parameter or have they forked the Chromium Repo and added custom behaviour? – Dominique Commented Apr 21, 2021 at 19:44
Add a ment  | 

1 Answer 1

Reset to default 10

To fix this is just about adding the parameter to deal with errors outputs into the catch statement. What this means is that Edge needs to know you are dealing with the error correctly.

So, I added:

     catch (err){}

And everything worked!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论