# How to make a Snap! block listener in javascript?

yeah that's why I got a bit confused Iframe is like putting another webpage inside a webpage right?

The autograders I know about have code both in the Snap! iframe (i.e., Snap! code) and code in the outer page (JS code). I'm guessing you're worried about students cheating if they have access to the Snap! part of the connection? If so, the problem isn't insecurity of the Snap! code; it's giving grades.

I see so how does Snap*!* code interact with external JS code?

Good question, but I don't really know the answer. See if I can find out...

Alright thank you so much for helping thus far!

I made "proof of concept" of modified Snap! https://replit.com/@DarDoro/SnapEmbed#snap.html
The "check" button builds the "spec" of the sprite[0]=>script[0] for simple script (no loops, if's, rings). You can test the entire spec or just count the lines.

function scriptSpec( script){
if(!script?.blockSpec) return "";
return script.blockSpec+";\n"+scriptSpec( script?.children.find( elem => elem?.blockSpec));
}

function checkIt(){
}


As for Snap! to JS, there is an official api.js. And JSFunction in Snap! itself to call JS code.