It is possible to call any action from JavaScript by just adding the "$scope." or "neo." prefix to the action name. Use the JavaScript syntax to send the parameters.
.

Quote from fkapnist on April 16, 2025, 10:13 amI have a subroutine ("MySub") in my VisualNEO Web app and I want to call it from within an iframe.
these commands don't work:
onclick="parent.MySub()" onclick="window.parent.MySub()"becaue they're trying to call a parent function, not a subroutine.
So how is it done?
thanks.
.
I have a subroutine ("MySub") in my VisualNEO Web app and I want to call it from within an iframe.
these commands don't work:
onclick="parent.MySub()" onclick="window.parent.MySub()"
becaue they're trying to call a parent function, not a subroutine.
So how is it done?
thanks.
.

Quote from emo on April 16, 2025, 10:53 am@fkapnist
If the iframe is not from the same origin as the main page, then you cannot directly access the functions or properties of the main document using
parentorcontentWindowdue to the Same-Origin Policy, which restricts access between documents from different domains to prevent potential security attacks.However, you can still communicate between the iframe and the main page using the
postMessage()method, which is a secure way to send messages between windows (parent and iframe) from different origins.In the iframe:
function sendMessageToParent() {
// Use postMessage to send a message to the parent (main page)
window.parent.postMessage("callMainFunction", "https://main-domain.com");
}in your page:
// Receiving the message from the iframe
window.addEventListener("message", function(event) {
// Validate the origin of the message
if (event.origin === "https://other-domain.com") {
// If the origin is the expected one, process the message
if (event.data === "callMainFunction") {
mainFunction();
}
} else {
console.log("Invalid origin");
}
});// Function that will be called from the iframe
function mainFunction() {
alert("Function in the main page called from the iframe!");
}
If the iframe is not from the same origin as the main page, then you cannot directly access the functions or properties of the main document using parent or contentWindow due to the Same-Origin Policy, which restricts access between documents from different domains to prevent potential security attacks.
However, you can still communicate between the iframe and the main page using the postMessage() method, which is a secure way to send messages between windows (parent and iframe) from different origins.
In the iframe:
function sendMessageToParent() {
// Use postMessage to send a message to the parent (main page)
window.parent.postMessage("callMainFunction", "https://main-domain.com");
}
in your page:
// Receiving the message from the iframe
window.addEventListener("message", function(event) {
// Validate the origin of the message
if (event.origin === "https://other-domain.com") {
// If the origin is the expected one, process the message
if (event.data === "callMainFunction") {
mainFunction();
}
} else {
console.log("Invalid origin");
}
});
// Function that will be called from the iframe
function mainFunction() {
alert("Function in the main page called from the iframe!");
}

Quote from fkapnist on April 16, 2025, 2:02 pmIf I go to Project>Properties>Advanced>Custom Metadata
I can add a javascript function.
And then I can call it from the iframe.
So I guess my question actually is "how to call a Neoscript subroutine from a javascript function"
.
If I go to Project>Properties>Advanced>Custom Metadata
I can add a javascript function.
And then I can call it from the iframe.
So I guess my question actually is "how to call a Neoscript subroutine from a javascript function"
.

Quote from fkapnist on April 16, 2025, 2:35 pmI think this is the way:
Calling actions from JavaScript
It is possible to call any action from JavaScript by just adding the "$scope." or "neo." prefix to the action name. Use the JavaScript syntax to send the parameters.
.
I think this is the way:
It is possible to call any action from JavaScript by just adding the "$scope." or "neo." prefix to the action name. Use the JavaScript syntax to send the parameters.
.