Accessing a specific scene from outside of a Tumult Hype document via QR code

I need to be able to load specific scenes from my hype document via QR code. It's an audio tour of an historic building. The plan is to hand out a printed page with QR codes that link to each stop on the tour. I tried the solution for linking to a scene but it only brings me to the first scene, I think due to the onclick, as the QR code really isn't a click. Is there a way for this javascript neophyte to get this done?

If you include the scene name hash in the QR code's URL, it should get you straight to the specified scene. The QR code's url should be something like: https://example.com/index.html#scenename -- and the target Hype document needs to have the function referenced in that post enabled on each scene.

Thanks, Daniel. So does that function need to be included in each scene in the Hype document?

Yes. In all scenes you want to include this functionality.

Thanks. So does that mean I don't need the onclick code? (Sorry for all the questions.)

Don't be sorry :wink: good to ask questions

After looking at this again I may have jumped the gun a little.

I just want to summarise what I have understood thus far and offer further advise.

From what I can tell you have a URL that is a HYPE website. (This is just assumption) So if there is nothing else happening other than when someone visits the url a HYPE document is the only thing there, then I would have the following code on the first and only scene i.e the scene that loads when ever someone visits the URL. This should be all you need

let hash = window.location.hash.substring(1);
hypeDocument.showSceneNamed(hash);

What this effectively does is look at whatever string is after the # within the URL and set the variable "hash" to that and then immediately invoke the method showSceneNamed() with the name of the scene being whatever is in the "hash" variable.

So, every time someone follows a link to your domain with a hashtag appended to the end your document should invoke the load scene from the first scene loaded and then send the user to whatever scene they need. Hope that makes sense :slight_smile:

And yes you won't need the onclick code as basically this is something that will automatically run once the Hype document (and Scene) load.

2 Likes

Thanks, DBear. I think I get it. So when the visitor scans the QR code (which has the main url and #scene, they should be taken directly to that scene? I'll give it a try and let you know.

Success! That solutions works perfectly. Thanks again DBear and Daniel for your patience and insight.

2 Likes