Web page link

Just starting out? Need help? Post your questions and find answers here.
Jarlve
Posts: 19
Joined: Mon Jun 18, 2018 6:10 pm

Web page link

Post by Jarlve »

Hey all,

I want to use HyperLinkGadget (or a button) to link to a web page so that clicking on it would open the web page in a new tab.

Possible?

Thanks.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Web page link

Post by Peter »

Code: Select all

Enumeration
  #Window
  #HyperLinkGadget
EndEnumeration

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 HyperLinkGadgetEvent()
  
  RunProgram("http://www.spiderbasic.com", "_blank")
  
EndProcedure

OpenWindow(#Window, 0, 0, 270, 160, "HyperlinkGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

HyperLinkGadget(#HyperLinkGadget, 10, 10, 250,20,"Red HyperLink", RGB(255,0,0))

BindGadgetEvent(#HyperLinkGadget, @HyperLinkGadgetEvent())
Greetings ... Peter
Jarlve
Posts: 19
Joined: Mon Jun 18, 2018 6:10 pm

Re: Web page link

Post by Jarlve »

Wonderful. Thank you very much Peter.

The ! indicate inline JS?
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Web page link

Post by Peter »

Jarlve wrote:Wonderful. Thank you very much Peter.
you're welcome.
Jarlve wrote:The ! indicate inline JS?
yes. It is also possible to encapsulate a JavaScript-Block with EnableJS / DisableJS,
but in this case the SpiderBasic-IDE incorrectly changes the if to If.

Greetings ... Peter
Jarlve
Posts: 19
Joined: Mon Jun 18, 2018 6:10 pm

Re: Web page link

Post by Jarlve »

Okay, thank you for the explanation.

The color of the HyperLink text remains black. Or is that because it was already clicked? Though it does not change back to its supposed color after restarting the webpage.

Using "SetGadgetColor(5,#PB_Gadget_FrontColor,RGB(0,0,255))" as workaround.
Jarlve
Posts: 19
Joined: Mon Jun 18, 2018 6:10 pm

Re: Web page link

Post by Jarlve »

Peter, my app uses a EditorGadget and it is possible to drag the HyperLink into the gadget which removes all of the buttons and shows this text in the Editor: http://127.0.0.1:9081/SpiderBasic_Compilation0.html
Post Reply