Page 1 of 1
getting the page URL
Posted: Mon Mar 31, 2014 5:03 am
by novaseer
Code: Select all
Procedure.s getURL()
!return window.location.host;
EndProcedure
Procedure.s getURLpath()
!return window.location.pathname;
EndProcedure
Procedure.s getURLparam()
!return window.location.search;
EndProcedure
if the URL is 'http://www.somesite.com/path/subpath/page.html?parameter1+parameter2', each procedure will give the following:
getURL... www.somesite.com
getURLpath... /path/subpath/page.html
getURLparam... ?parameter1+parameter2
Re: getting the page URL
Posted: Wed Apr 23, 2014 10:38 pm
by eddy
Hi,
I updated your last function:
Code: Select all
Procedure.s getURLparam(ParamName.s="")
If ParamName
!var results = new RegExp('[\\?&]' + v_ParamName + '=([^&#]*)').exec(window.location.search);
!return (results==null) ? null : decodeURIComponent(results[1]) || 0;
Else
!return window.location.search;
EndIf
EndProcedure
if the URL is '
http://www.somesite.com/path/subpath/pa ... e&arg3=200'
getURLparam("arg3") will return "200"
getURLparam("arg2") will return "true"
getURLparam("arg1") will return "HELLO WORLD"
getURLparam() will return ?arg1=HELLO%20WORLD&arg2=true&arg3=200
Re: getting the page URL
Posted: Sat May 31, 2014 9:35 am
by novaseer
nice