Extreme basic question (grease monkey)

Im trying to add this to my local page via grease monkey just for practicing wise

document.body.innerHTML += '<center><input type="submit" onclick="alert("BooYa!")" value="Click Me !"></center>';

somethings wrong at ** onclick=“alert(“BooYa!”)” **

just cant figure out how to do this…

any advices regarding this? thanks a million

I’ve seen quite a few error messages but I’ve never seen the “something’s wrong” one :wink:

What does the error console say?

doesnt say anything just trying to alert… and its not

Hmmm. I tried it and it says

Error: syntax error
Source File: file:///C:/My%20Documents/TEST/noalert.html
Line: 1, Column: 5
Source Code:
alert(

with a _____^ pointing to after the parenthesis

Makes me think it might be the use of unescaped double quotes again.

mmm any idea how to fix it?

It could be done more than one way, some more “messy” looking than others.

Javascript uses single and double quotes to “group what’s inside” them.

The problem comes when you have them nested inside of each other. eg.

instead of grouping like
"outer “inner1 " inner2” end inner1" end outer"

it thinks you mean
"outer "inner1 " inner2" end inner1" end outer"

So you can switch back and forth between single and double quotes

And you can try escaping quotes for the ones meant to be written rather than interpreted in that line as code eg.
“outer 'inner1 \” inner2\" end inner1’ end outer"