Create a redirect button using URL parameters

Hi,

I work in Marketing and my HTML and Javascript knowledge is not that good. I use Hype because it allows me to design visually and then export to HTML5 that I can publish in our websites and product tutorials.

Right now I have an issue. I need to build a little launcher page with two buttons. The second button will be used to direct users to their own personal page. I have built the page in Hype and saved it with a name (i.e. redirect.html) What I need is that when I invoke that page using an url like this:
h t t p : / / webserver.ourdomain.com/redirect.html?username=users_name&token=user_token

Then the button I have built, when pressed, will take the user to another website (in a new window) like this:
h t t p : / / newwebsite.domain.com/redirectedsite/users_name?username=users_name&token=user_token

Where the users_name and user_token are the ones harvested from the URL where I stored my hype page. That is, for a username of albert.einstein@yahoo.com and token=abcdefg I would invoke my Hype page going to:
h t t p : / / myhypewebsite.domain.com/redirect.html?username=albert.einstein@yahoo.com&token=abcdefg

And the button that I placed on it, when clicked, would open a new window and point it to something like:
h t t p : / / redirectedsite.domain.com/project/albert.einstein@yahoo.com?username=albert.einstein@yahoo.com&token=abcdefg

Yes, the redirected page needs to use username twice, I didn’t set that requirement, I have to live with it.

I have found on the Internet how to harvest parameters from a web URL and how to build a destination URL from them, however, I don’t know where to place this code on Hype, and I don’t know how to make the button call that built URL when I click on it (probably running a javascript function, I guess). Any charitable soul want to illuminate me?

Thanks a million in advance!!!

Hi,
Can you post the code you have…

This is what I have to harvest parameters from a URL:
(function(){
var user_name = getParameterByName(“username”);
var user_token = getParameterByName(“token”);
var rootUrl = “http://redirectsite.domain.com/project/”;
var myURL = rootUrl + user_name + ‘?username=’ + user_name + ‘&token=’ + user_token;
}());

That would build a variable called myURL with the new URL. But I don’t know how to have a button open a new blank window and point it to that URL. And also, I don’t know where to implement this function above (I would have to give it a name too) if I should run it automatically at the scene load, and if myURL var will actually survive outside of the function or will be valid only within the function (keep in mind that my knowledge of Javascript is limited, the last time I ever coded something was using C++ about 13 years ago).

Thanks

Can nobody help me here? nobody from Tumult can tell me how to do this?

Hi Carlos

Sorry nobody has replied for a while.

I will attempt to shed some light on this for you

declare your variable without the "var" so this will make it accessible outside your function.

but I would just run this "new function" as a click event on your button

var user_name = "Carlos";
var user_token = "46858ye87h38";
var rootUrl = "http://redirectsite.domain.com/project/";
var myUrl = rootUrl + user_name + '?username=' + user_name + '&token=' + user_token;

window.open(myUrl, "_blank");

Hope this helps!

D