How to call a JS function?

Using Javascript from SpiderBasic
User avatar
Caronte3D
Posts: 187
Joined: Sat Nov 23, 2019 5:21 pm
Location: Some Universe

How to call a JS function?

Post by Caronte3D »

I know how to call SpiderBasic functions from JavaScript (prefix: "f_"), but... how to call JS functions from SpiderBasic side?
I tied:
! myFunction()
but an error says: Uncaught ReferenceError: myFunction is not defined
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How to call a JS function?

Post by Peter »

This (window.myFunction = myFunction) allows you to make a function globally accessible:

Code: Select all

! function myFunction() {
!   alert("!");
! }
! window.myFunction = myFunction;
Call:

Code: Select all

! myFunction();
User avatar
Caronte3D
Posts: 187
Joined: Sat Nov 23, 2019 5:21 pm
Location: Some Universe

Re: How to call a JS function?

Post by Caronte3D »

That's works!
Thanks (again) by your help ;)
Post Reply