demorouter2.pas 629 B

12345678910111213141516171819202122232425262728
  1. program demorouter2;
  2. {$mode objfpc}
  3. {$H+}
  4. uses web, classes, js, sysutils, webrouter, frmdemo;
  5. Procedure ShowForm (URl : String; aRoute : TRoute; Params: TStrings);
  6. Var
  7. s : string;
  8. begin
  9. S:=Params.Values['ID'];
  10. document.body.innerHTML:='';
  11. TDemoForm.Create(StrToIntDef(S,1),True);
  12. end;
  13. begin
  14. // Leave this if you want to use the #hash history mechanism.
  15. // This will work in all cases.
  16. Router.InitHistory(hkHash);
  17. // Uncomment this if you want to use HTML5 history.
  18. // Router.InitHistory(hkHTML5,'http://localhost:3000/');
  19. Router.RegisterRoute('form/:ID',@ShowForm,True);
  20. Router.Push('form/1');
  21. end.