Just starting out? Need help? Post your questions and find answers here.
Dirk Geppert
Posts: 284 Joined: Fri Sep 22, 2017 7:02 am
Post
by Dirk Geppert » Tue Sep 04, 2018 1:31 pm
I would like to call a function() from a link. Why doesnt work this with SpideBasic?
Code: Select all
Procedure MyFunc ()
Debug "You've clicked the link!"
EndProcedure
If OpenWindow(0, 0, 0, 270, 160, "TextGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), "")
txt.s = "<h3>Click Test</h3><p>Please click<a href=" + Chr(34) + "#" + Chr(34) + " onclick=" + Chr(34) + "MyFunc();" + Chr(34) + ">here</a>"
SetGadgetText(0, txt)
EndIf
Dirk Geppert
Posts: 284 Joined: Fri Sep 22, 2017 7:02 am
Post
by Dirk Geppert » Tue Sep 04, 2018 1:36 pm
Got it
Code: Select all
Procedure MyFunc ()
Debug "You've clicked the link!"
EndProcedure
If OpenWindow(0, 0, 0, 270, 160, "TextGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), "")
txt.s = "<h3>Click Test</h3><p>Please click<a href=" + Chr(34) + "#" + Chr(34) + " onclick=" + Chr(34) + "window.parent.f_myfunc();" + Chr(34) + ">here</a>"
SetGadgetText(0, txt)
Debug txt
EndIf
Peter
Posts: 1093 Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:
Post
by Peter » Tue Sep 04, 2018 1:37 pm
Hello Dirk,
SpiderBasic converts procedure names into lower case letters and sets a 'f_' - prefix in front of them. For this reason, your call must look like this:
Code: Select all
txt.s = "<h3>Click Test</h3><p>Please click<a href=" + Chr(34) + "#" + Chr(34) + " onclick=" + Chr(34) + "f_myfunc();" + Chr(34) + ">here</a>"
Greetings ... Peter