I have a Snap! instance running locally in an iFrame at a URL that is whitelisted for authentication. Is there a way to subscribe to an event that is fired when a user opens a Snap! project from the cloud? If so, how would I subscribe to such an event and access the URL of the Snap! project that was opened? Thanks.
If you add a runFlag flag to the url, you will get green flag on start. You can also use the when block with not a transient variable, and set it to true in the script.
Hmm, at one time I wanted to be able to have a STARTUP block in a project that would auto-run when the project is loaded, but Jens vetoed that because he wanted to avoid people writing projects that delete all your projects, or something, before you even know they're running. But I guess we can achieve the same effect this other way. @jens, does this worry you? Or is it okay?
You could make it so it starts as if the stop button was pressed. You could also disable JS calling (don't disable the function blocks) until a flag or key is pressed. You would have to be make sure to not allow it just because the project broadcasts __shout__go__.
I can already make a link that runs on load by removing the noRun flag. It's even the default!
There is no way to do this without JS. window.location contains a lot of data, including the hash and the href. It also contains the protocol, the host, the port, and the pathname.
Can you put the javascript block in the project? I hav'nt really used iframes. I wish they still had normal frames. (they wouldn't help in this case however)
@spaceelephant Yeah, but, unfortunately, window.location from within the Snap! project, just like window.location from within the iFrame itself on my website, does not contain the URL of the Snap! project from the cloud, which is what I am looking for. Any other ideas?
However, unfortunately, it doesn't provide me with the information I am looking for on my website, from which I am running Snap!:
I believe the confusion is coming from the fact that I am not using solely an iFrame; I am using Snap!'s source code, hosted on my website, within an iFrame, from which users can log in and open their Snap! cloud projects. Any other ideas for catching the Snap! cloud URL of projects opened on my site would be greatly appreciated. Thanks for the help so far!
In the snap project, run window.parent.loadHash(window.location.hash);.
In your website, define a function window.loadHash that will be run to get the hash.