Custom Javascript dilema

Hi there,

I am building some very basic elements in Hype and have been given some custom javascript code that I have to include in order for this to work in an online platform.

Unfortunately I am not able to get this to work and was wondering if I am missing something or if Hype requires this to be done in a specific way.

Anyway, here is the javascript:

function isBrowserClient() {
            try {
                if (window.name.slice(0, 4) == "twx-") {
                    return true;
                } else if (window.location.hostname.indexOf("twixlmedia.com") > 0) {
                    return true;
                }
            } catch (exception) {
                return false;
            }
        }

        function goToURL(url) {
            if (isBrowserClient()) {
                twxHandleURL(url);
            } else {
                window.location.href = url;
            }
        }

        var title = document.getElementById("title");
        title.addEventListener('click', function() {
            goToURL("tp-collection://hidden-collection");
        });

Any advise would be appreciated

It looks like you created a function to check the URL, then load a different url. It's not with the HTTP/HTTPS protocol though.

Anyway, are you actually running the function?

If not, it's like building a car in the garage and then never driving it.

Also, I have a Hype template that seems similar to what you're trying to do…

It checks if the URL is Photics.com. If it is, a different scene is loaded. That seems to be the general idea of what you're trying to do. There's a video too…

Basically, the logic is… if the URL is “this”, then do “that”.

If @photics's reply didn't help, it would be useful to attach a zip of your .hype document so we can take a look in context.