wprins Posted February 20, 2017 Share Posted February 20, 2017 I've set up processing to to look for and capture parameters passed via the URL (e.g. GET parameters, captured in MainModule.BeforeLogin, then deal with login/auth etc, and then used later etc.) However, the URL parameters stay on the browser address. I'd like to remove them after capture but I'm not sure how to get this effect in the browser. I assume I'd have to inject some JS at some suitable point (perhaps using UniSession.AddJS()?) With plain javascript one could do e.g. <html> <head> </head> <body> <div id="urldiv"></div> <script type="application/javascript"> var urldiv = document.getElementById('urldiv'); urldiv.innerHTML = '<p>Page opened with: '+window.location+'</p>'; window.history.replaceState({} , '', window.location.origin + window.location.pathname ); urldiv.innerHTML = urldiv.innerHTML + '<p>Location changed to: '+window.location+'</p>' </script> </body> </html> Opening this page with e.g. ?foo=bar will result in the query params being removed from the URL in the browser without a page reload. (I have a feeling this ought to be possible without too much fuss, and have hunted around the demos and so on to try and find an example, and have also some small amount of time inspecting e.g. UniSession but it's not been obvious what to do where, apologies if I've missed the obvious.) Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted February 21, 2017 Share Posted February 21, 2017 Hi Please use this code. This is HTML5 History API. UniSession.AddJS('history.replaceState({}, "some title", "/");'); Note : This can now be done in Chrome, Safari, FF4+, and IE10pp4+! 1 Quote Link to comment Share on other sites More sharing options...
GerhardV Posted February 23, 2017 Share Posted February 23, 2017 Is it maybe possible that you can try to pass the parameters in the header instead of in the URL? Then they wont be visible in the first place. Quote Link to comment Share on other sites More sharing options...
wprins Posted February 27, 2017 Author Share Posted February 27, 2017 Is it maybe possible that you can try to pass the parameters in the header instead of in the URL? Then they wont be visible in the first place. In general it would be beter yes (actually having them in the body (POST) be better still perhaps IMHO). But UniGUI seems to use GET for the client side event propagation for whatever reason (instead of POST). Also in my particular case I don't have the luxury of passing parameters any way other than via URL. (It is a green screen application displaying the URL, with the terminal emulator being able to recognize a URL and launch the browser from it. Using headers or POST in this context would unfortunately require more smarts from a piece of software I don't control.) Thanks for the comment though, in the more general case I would be very much interested to know how to pass them via header or via POST (if possible.) Quote Link to comment Share on other sites More sharing options...
GerhardV Posted March 22, 2017 Share Posted March 22, 2017 Any REST client should give you the ability to add header values. Here is an example where I read one of the header values in TUniServerModule. procedure TUniServerModule.UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean); var dm : TdmReportData; begin if ARequestInfo.URI='/report/finsummary' then begin dm := TdmReportData.Create(nil); try dm.qryReport.Connection := dm.FDConnection; AResponseInfo.ContentText := dm.GenerateReportPDF(repFinSummary, '') + ' header [user] = ' + ARequestInfo.RawHeaders.Values['user']; AResponseInfo.ResponseNo := 200; AResponseInfo.WriteContent; Handled := True; finally dm.Free; end; end; end; Quote Link to comment Share on other sites More sharing options...
erich.wanker Posted March 22, 2017 Share Posted March 22, 2017 i dont know if it helps - but: i use a index.php file fpr my uniGui-App ( a iframe loads the unigui) .. so the adress in the browser is www.mydomain.com if i want to send parameters - i send the parameters to www.mydomain.com/unigui.dll?value=something (a new instance of unigui will start..) if the unigui.dll becomes parameters, this instance of unigui search the allready running session of the user - and sends the value to the open session and closes itselfe ... begin // Suche Session und starte Suche ASessionList := UniServerModule.SessionManager.Sessions.SessionList; // .SessionList. ist;// .LockList; try for I := 0 to ASessionList.Count -1 do begin USession := TUniGUISession(ASessionList[i]); M := USession.UniMainModule as TUniMainModule; if UniApplication.UniSession.SessionID <> USession.SessionId then // Do not close my OWN Session begin if M.benutzernummer = handy_user_id then begin M.syn_user :=handy_syn_user; M.syn_layer :=handy_layer; M.syn_nummer :=handy_nummer; // send parameters to the user session M.syn_name :=handy_name; M.syn_art :=handy_art; end; end; end; finally uniapplication.terminate; // ... and close the not needed session; end; end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.