Example with external JavaScript in separate file (does not work):
Code: Select all
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 0, 0, 600, 300, "", #PB_Web_Edge)
html$="<button id=''demo'' type=''button'' onclick=''myFunction()''>Click Me</button><script src=''file:///"+GetCurrentDirectory()+"myScript.js''></script>"
html$=ReplaceString(html$,"''",Chr(34))
Debug html$
SetGadgetItemText(0, #PB_Web_HtmlCode, html$)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Select all
function myFunction() {
document.getElementById("demo").innerHTML = "Clicked";
}
Example with embedded JavaScript (does work):
Code: Select all
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 0, 0, 600, 300, "", #PB_Web_Edge)
html$="<button id=''demo'' type=''button'' onclick=''myFunction()''>Click Me</button><script>function myFunction(){document.getElementById(''demo'').innerHTML = ''Clicked'';}</script>"
html$=ReplaceString(html$,"''",Chr(34))
Debug html$
SetGadgetItemText(0, #PB_Web_HtmlCode, html$)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Select all
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 0, 0, 600, 300, "file:///"+GetCurrentDirectory()+"test.html", #PB_Web_Edge)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Thank you very much & Regards