Do not receive event from BindWebViewCallback
Posted: Thu Mar 21, 2024 7:14 am
Hello all.
Im kinda lost why this small and simple Code does not work.
The function "myFunction" is called and working within the browser but the binding of these function does not work.
HTML Code of file website.html:
PB Code:
Im kinda lost why this small and simple Code does not work.
The function "myFunction" is called and working within the browser but the binding of these function does not work.
HTML Code of file website.html:
Code: Select all
<!DOCTYPE html>
<html>
<body>
<button type="button" id="Mein_Button">Mein Button</button>
</body>
</html>
<script>
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("Mein_Button").addEventListener("click",myFunction);
});
function myFunction() {
alert("Test");
};
</script>
Code: Select all
Global idWND = OpenWindow(#PB_Any,0,0,1024,768,"WebView Test",#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
Global idWVW = WebViewGadget(#PB_Any,0,0,1024,768,#PB_WebView_Debug)
Procedure myFunction(jSONParams$)
Debug "PB Event!"+jSONParams$
ProcedureReturn UTF8("")
EndProcedure
ReadFile(0,"website.html")
str$ = ReadString(0, #PB_File_IgnoreEOL )
CloseFile(0)
SetGadgetItemText(idWVW, #PB_WebView_HtmlCode,str$)
BindWebViewCallback(idWVW,"myFunction",@myFunction())
Repeat
Event.i = WaitWindowEvent()
Until Event.i = #PB_Event_CloseWindow