Menu buttons and calling javascript functions?

Just wondering if there is anyway of linking the menu buttons to trigger javascript functions on current page, aswell as calling hescript macro functions or open pages ? if not possible directly thinking about using menu buttons to set a global variable (via a hescript macro), then the javascript via an event listerner detects the global variable set, then triggers a function. Is there a way to do it that way, and if so, could any help be given ?

Basically got a javascript based editing tool, and ideally would like to link a custom menu button to a javascript submit script to submit a hidden form holding user graphical data in the form of node vectors (shape editor).

Thanks.

Yes, it’s possible to call javascript. Use

 javascript:yourfunction()

Thanks for that…

Hi, sorry to bring this up again, but in relation to an early thread I started but now closed, I cannot get the solution to work.

To recap got some visual control toolbar buttons I ideally want to allocate to trigger some javascript functions. Was told earlier that just using javascript:yourfunctioncode() to allocate to the buttons would work (via the visual control editor), alas I cannot get that to work. On compiling I get a ‘main script error’ and this is before the application is even run. If it is possible, any idea what I could be doing wrong ?

Perhaps there was an earlier misunderstanding - this isn;t allocating javascript functions to html coded buttons but to the visual control toolbar buttons (which you can allocate to hescript and other pages). Tried adding javascript:loadshape() function call to the hescript entry, but on compiling produces an error message,

Thanks.

Could you please post a screenshot of how you entered the javascript:loadshape() function?

Sure getting one done now - image attached here. Thanks.

This is odd now, as made no changes, came back to my project (company demo), re-opened it, went to recompile and now recompiled fine. No compile alert message. However, now when I go to run the application, and click on the load shape toolbar button i get an alert saying no function found, despite the javascript function (test) been on the page in question.

<script>
function loadshape() {
alert("Test Message For Loading Shape");
}
</script>

Not sure what I can be doing wrong.

Thanks to the screenshot. It shows the problem.

javascript:loadshape() should be in “Show this page/URL” because it’s a URL to pass to the web browser.

“Execute this script function” is an option to execute an HEScript function, not a JavaScript one.

Thanks for the reply and help, but even when I try moving javascript:loadshape() to “Show this page/URL” it still isn’t working - see error message on page I get when I click on the SAVE shape button and try to trigger the saveshape() javascript command… the function is definately in the page.

No idea why it won’t trigger.

This is how I currently have the loadshape() function call - see attached image - and in the previous post it shows the error response when the similar / identical saveshape button is clicked - and should have triggered the saveshape() javascript function. Whether saveshape or loadshape buttons are pressed a similar error message is returned, and the function code is 100% definately on the page.

Thanks again for your help.

Seeing if I can trigger an event via hescript and global variables as cannot get javascript functions to be called at all.

I forgot to ask: are you using Chromium or Trident engine in your project?
You can call JavaScript with HEScript too: see ExecuteHTMLScript at http://www.exeoutput.com/help/scriptreference

Thanks for the feedback - to answer your question using the Webkit Chromium engine.

Tried both engines - does exactly the same thing.

Thanks again.

Tried using the following…

Decided to try a simple page with the following…

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Box2d Shape Editor</title>


    <script type="javascript">
    function loadshape() {
    alert("load shape");
    }
    function saveshape() {
    alert("save shape");
    }
    </script>

</head>

<body>

</body>
</html>

Then declared two new hescript procedures in Macros block…

procedure RunLoadShapeJavascript;
begin
ExecuteHTMLScript("loadshape()", "JavaScript");  
end;     
 
procedure RunSaveShapeJavascript;
begin
ExecuteHTMLScript("saveshape()", "JavaScript"); 
end;   

Then attached RunSaveShapejavascript and RunLoadShapeJavascript hescript calls to two menu buttons…

via Macros.RunSaveShapeJavascript and Macros.RunLoadShapeJavascript

Then compiled and came to test - still not working. Using Webkit engine, and using version 7.1 of exeoutput.

No idea what I could be doing wrong.

Definitively a problem with the Webkit engine. It should work with the Trident engine.
We’ll look at this.

Thanks… Just out of interest can Webkit engine javascript side access Exeoutput declared global variables, can it also change a exeoutput global variable ?

Only other method I can think of to get these buttons working (alas cannot use Trident engine) is to get the toolbar buttons to set a global variable when pressed and use a javascript eventlistener to see if any of these global variables have been set, and if so, trigger appropriate function calls depending on the variable state of the global variable ?

Thanks.

Yes, you can access global variables using javascript - http://www.exeoutput.com/help/javascriptexeoutput but note that the title on the help is wrong… this is for webkit not Trident engine.

Fixed the documentation title error. Thanks!