Replacing/updating URL does not work.

Join us! Share tips and solutions with WebAnimator users around the world.
Locked
WA_Luke
Posts: 2

Replacing/updating URL does not work.

Post by WA_Luke »

Hello,

My software: WebAnimator plus 3.0.1.
I place a number of symbols on the page which I use as buttons to go to different websites.
The symbols have a default style and URL.
The new information, like height, width, left, top and the URL comes from a database.
I also have one butten on the page that when clicked, loads new information for the symbols.
So, each button needs to get a different location and size on the page and a different URL.

eg. The initial value for a symbol is height=110, width=226, left=0, top=0 and initial URL is https://www.casashops.com/.
This works fine.

I have this code to alter the symbol:

var x = document.getElementById("Butt1");
x.style.height = "110px";
x.style.width = "110px";
x.style.left = "0px";
x.style.top = "229px";
x.setAttribute('href', 'http://www.blokker.be/');

The styles get updated, but the URL remains unchanged.
Any idea how I can update/replace the URL?

Thanks.

User avatar
Oskar007
Posts: 295
Contact:

Post by Oskar007 »

Hello,
is it possible to see an example of this in order to better understand where the problem lies?
greeting
Oskar007

WA_Luke
Posts: 2

Post by WA_Luke »

Hello,

It's a very simple setup. Start WA plus 3 and use the default scene. Put a rectangle symbol, width:226, height:110, at the left/top of the scene and change the ID to Butt1.
In properties, add an event, on mouse click, Action: Open URL and enter any URL you like.
Now if you preview the scene in your browser there is just the rectangle. When you click on it, the URL will open in a new tab.
Close the browser.

In WA, goto Scenes, and add a new Javascript function. Rename the default to MoveChangeURL and edit the function:

var x = document.getElementById("Butt1");
x.style.height = "110px";
x.style.width = "110px";
x.style.left = "0px";
x.style.top = "464px";
x.setAttribute('href', 'https://www.tutorialrepublic.com/javascript-tutorial/');
}

This function resizes the symbol to a square 110 by 110 and moves it down form position 0,0 to position 0,464.
It also should replace the original URL by a new one (any URL different from the initial one will do).

Now place a button on the scene (default text Click is OK)
In the properties of the button add an event, on mouse click, Action: Execute custom function,
and select MoveChangeURL from the list (there should be only 1 item in the list).

Start the preview. When you click on the rectangle a new tab opens to the initial URL. Now close this tab.
When you Click the button (right/bottom), the rectangle becomes a square and it's moved to the new location (x.style.top = "464px";). When you click on the square it should open the replaced URL.
Unfortunately the URL is not updated, so the initial page is shown.

Any idea why it's not updated? Should I use something different than setAttribute?

Kind regards.

User avatar
Oskar007
Posts: 295
Contact:

Post by Oskar007 »

Hello,
I try to understand this arrangement and see what happens to me.
Give me a call.
greeting
Oskar007

Locked