Home > Back-end >  ie return ')' expected when trying to make bookmarklet
ie return ')' expected when trying to make bookmarklet

Time:12-01

writing a bookmarklet, which is about 300 lines of JS code. been getting all kind of error all day. what I did was write the JS and test in console then I use https://www.toptal.com/developers/javascript-minifier/ to compress the code then add javascript:(code)() to it. the latest problem I have is adding the following function to my code and keep getting expected ')' after I convert it with other code to bookmarklet. it runs fine in console, and the code alone doesn't give me error, only when combined with other codes.

    function checkTEST() {
    clickDynatreeSub("Special TEST Requirement");
   //this is the function I wrote to click basked on innerText
    setTimeout(function() {
        if (document.getElementById('ctl01_oldtestType').value != "hydro") {
            addmessage(("test not hydro"), "red");
        } else {
            addmessage(("test hydro........... OK"), "green");
            Checkdocuments();
        }

    }, 8000);
}

CodePudding user response:

I was reading online and found that the IE bookmarklet can only take 5119 characters. And upon examine my own code, adding extra function causing it to exceed 5119. Thus, code got chopped off resulting something like the following to cause expected ")" or unterminated string.

Function a() {var test = " I am a strin........
  • Related