Share your advanced knowledge/code with the community.
novaseer
Posts: 5 Joined: Wed Feb 26, 2014 1:34 am
Post
by novaseer » Mon Mar 31, 2014 5:03 am
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
eddy
Posts: 124 Joined: Thu Mar 27, 2014 8:34 am
Post
by eddy » Wed Apr 23, 2014 10:38 pm
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