I'm trying to execute a JavaScript function to see if an element exists in a webpage, but instead of receiving true/false, I'm getting a SyntaxError.
JavaScript:
javascript: var foo = function() { if (document.getElementById('bar') != null) return true; else return false; }; foo();
Error:
I/chromium: [INFO:CONSOLE(1)] "Uncaught SyntaxError: missing ) after argument list", source: (1)
I've run it through several JavaScript formatters, but I can't find the source of the error. Any ideas?
javascript:label? How about to simplify the code since it seems you don't really need a function. This should do exactly the same:document.getElementById("bar") != null