Welcome! Log In Create A New Profile

Advanced

WD - Using Javascript on Html control

Posted by Gianni Spano 
WD - Using Javascript on Html control
February 15, 2021 07:47PM
Hello to all

I'm trying to figure out, and if it is possible, to add an 'eventListener' in javascript code inside a Windev Html control.

I know that is possible to load the scripts from an html page, but if i try to declare a simple script like this below, the control doesn't react to the 'onmousemove' and 'onmouseover'.


<html>
<body>
<h2>JavaScript addEventListener()</h2>

<p>This example uses the addEventListener() method to add many events on the same button.</p>

<button id="myBtn">Try it</button>

<p id="demo"></p>

<script>
var x = document.getElementById("myBtn");
x.addEventListener("mouseover", myFunction);
x.addEventListener("click", mySecondFunction);
x.addEventListener("mouseout", myThirdFunction);

function myFunction() {
document.getElementById("demo").innerHTML += "Moused over!<br>";
}

function mySecondFunction() {
document.getElementById("demo").innerHTML += "Clicked!<br>";
}

function myThirdFunction() {
document.getElementById("demo").innerHTML += "Moused out!<br>";
}
</script>

</body>
</html>


Does anyone have tested some solution in Windev?

Thanks
Gianni
Re: WD - Using Javascript on Html control
February 18, 2021 05:53AM
Hello Gianni,
I do not use webdev but saw this in the help

JSEvent
Re: WD - Using Javascript on Html control
February 18, 2021 01:25PM
Hello Cabinetman

Thank for your reply, but i'm not using Webdev, but Windev on an Html ctrl inside a form.

It seems that the Html ctrl is not fully compatible to use an "eventListener" function inside an Html page o Html file loaded in a Html ctrl.

Of course this is a limitation on its use.
What i'm trying to do is to load a marina map (an image as background), reading some rectangles and/or polygons coordinates to intercept the click to load the informations of the berth clicked and so on.

This could be a solution for my application, but it doesn't run for its limitation. confused smiley

Thank anyway for your attection.

Gianni
Re: WD - Using Javascript on Html control
February 18, 2021 02:01PM
Hi Gianno,

I did a quick test and your code works in Windev 22.
So I think you forgot to check the option "Allow the execution of scipts" on the general tab of the control.

Best regards,
Piet
Re: WD - Using Javascript on Html control
February 18, 2021 07:56PM
Hello Piet

Yes, you are right. A stupid forgetfulness. :-)

Thanks

Gianni
Author:

Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: