Link or Close

Just starting out? Need help? Post your questions and find answers here.
bmld76
Posts: 27
Joined: Wed May 24, 2023 5:10 pm

Link or Close

Post by bmld76 »

hello,

I don't found how to quit the spider page. I want to close it or put a link to open an another page.

Cordially
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Link or Close

Post by Peter »

Code: Select all

Procedure ButtonEvent()
  If MessageRequester("Really?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
    ! window.close();
  EndIf
EndProcedure

OpenWindow(0, 0, 0, 300, 200, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 280, 180, "Close window (current tab)")
BindGadgetEvent(0, @ButtonEvent())
bmld76
Posts: 27
Joined: Wed May 24, 2023 5:10 pm

Re: Link or Close

Post by bmld76 »

Thank, but this commande don't work on IPAD only on computer.

I correct : it works when you call the page from an another.

Cordially
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Link or Close

Post by Peter »

I don't own an iPad, so I'm out.
bmld76
Posts: 27
Joined: Wed May 24, 2023 5:10 pm

Re: Link or Close

Post by bmld76 »

Hello,

I found a simple solution. After creating the app, I add in the index.html a button to link an another site.
User avatar
Paul
Posts: 210
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Link or Close

Post by Paul »

Maybe you are looking for this procedure? (I think it also came from Peter)

Code: Select all

Procedure RunProgram(Filename.s, Parameter.s="")
  !  if (v_parameter != "") {
  !    var win = window.open(v_filename, v_parameter);
  !    win.focus();
  !  } else {
  !    window.open(v_filename);
  !  }
EndProcedure


Procedure CloseWindowEvent()
  WindowID=EventWindow()
  Select WindowID
    Case 0      
      RunProgram("https://google.com","_parent")
      CloseWindow(0)
  EndSelect
EndProcedure

Procedure GadgetEvent()
  GadgetID=EventGadget()
  Select GadgetID
    Case 1
      RunProgram("https://spiderbasic.com")
  EndSelect
EndProcedure

OpenWindow(0, 0, 0, 300, 200, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 10, 10, 280, 180, "Visit SpiderBasic")
BindGadgetEvent(1, @GadgetEvent())
BindEvent(#PB_Event_CloseWindow,@CloseWindowEvent())
bmld76
Posts: 27
Joined: Wed May 24, 2023 5:10 pm

Re: Link or Close

Post by bmld76 »

Very interesting, I will test it . Thank
bmld76
Posts: 27
Joined: Wed May 24, 2023 5:10 pm

Re: Link or Close

Post by bmld76 »

So, the procedure works correctly. But, is it possible to find doc ob this.

what is a line beginning with !

Cordially
User avatar
Paul
Posts: 210
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Link or Close

Post by Paul »

Lines beginning with ! are inline javascript, they are not native SpiderBasic commands.
bmld76
Posts: 27
Joined: Wed May 24, 2023 5:10 pm

Re: Link or Close

Post by bmld76 »

ok, thank
Post Reply