Page 1 of 1

Adding custom javascript in Oblect Properties > Events

Posted: Sat Sep 03, 2022 8:58 am
by Aris
Hello.

Having an animated gif image (with 5 loopings) I wish to have a user of webpage thw ability to repeat the the animation.

I tried to add in Image > Events the following:
Event: onclick
Action: javascript
Target: history.go(0); This is what I added by hand.

The webpage is reloading and the image proceeds to an new repetion.

Tell me, please, is there something wrong here? I am asking because I added the code by hand.

Thank you.

Re: Adding custom javascript in Oblect Properties > Events

Posted: Sat Sep 03, 2022 9:54 am
by Pablo
Isn't the GIF animation automatically repeated?

Re: Adding custom javascript in Oblect Properties > Events

Posted: Sat Sep 03, 2022 3:55 pm
by Aris
The GIF is repeated automatically only 5 times (it is my choice). But since the image (showing the effect of the mistral wind) has dimensions on the website of 1000X600 pixels, I chose to repeat it only 5 times. If the user wishes to see the wind movement again, he can refresh the webpage to see again the animation.

Of course, I would like just refresh the layoutgrid of the image and not the whole webpage, but I ran into a lot of trouble.

Do you think the history.go(0); option --the way I incorporated it-- will cause problems?

Thank you.

Re: Adding custom javascript in Oblect Properties > Events

Posted: Sat Sep 03, 2022 4:01 pm
by Pablo
If it works for you then I think it's ok.

Re: Adding custom javascript in Oblect Properties > Events

Posted: Sat Sep 03, 2022 7:35 pm
by crispy68
@aris,

Is this what you are after?
DEMO

Re: Adding custom javascript in Oblect Properties > Events

Posted: Wed Sep 07, 2022 12:43 pm
by Aris
It's the solution I was looking for!

Thank you.

may I use it?

Re: Adding custom javascript in Oblect Properties > Events

Posted: Wed Sep 07, 2022 12:46 pm
by wwonderfull
Aris wrote: Wed Sep 07, 2022 12:43 pm It's the solution I was looking for!

Thank you.

may I use it?
Although it is a demo but you can do the same thing in your project. It was given to use. So Yes, you can can use it without a doubt.

Re: Adding custom javascript in Oblect Properties > Events

Posted: Wed Sep 07, 2022 12:56 pm
by crispy68
@Aris,

Yes! you can use it. Just wanted to make sure it was what you were looking for.

Give me a little bit and I will provide the steps here and share how to do it.

Re: Adding custom javascript in Oblect Properties > Events

Posted: Wed Sep 07, 2022 5:47 pm
by crispy68
Here are the steps:

1. Open up your button (in my demo I'm using a themeable button with button type set to "link button"), go to the link tab and enter the following in the URL:

Code: Select all

javascript:restart('Image1','images/NameOfGif.gif');
You will need to replace "Image1" with the ID of your gif image and replace "images/NameOfGif.gif" with the url path and gif name. If all of your images are placed into the default images folder then you only need to change the name of your gif in the above code.

2. Open up an html object, set Type = Before </body> and enter the following:

Code: Select all

<script type="text/javascript">function restart(id,url){var img=document.getElementById(id);img.src="";img.src=url;}</script>

Re: Adding custom javascript in Oblect Properties > Events

Posted: Wed Sep 07, 2022 8:15 pm
by Aris
Thank you, crispy68.

Your assistance is valuable!!!

Re: Adding custom javascript in Oblect Properties > Events

Posted: Thu Dec 22, 2022 5:39 pm
by windsurfer
How would i call a custom javascript in the event ?

Re: Adding custom javascript in Oblect Properties > Events

Posted: Thu Dec 22, 2022 5:56 pm
by crispy68
Choose javascript as the action and enter the code.