javascript - try to remove the string from link but its not working -


i trying remove pagenum=2 url, value 2 can dynamic following url

var urlval = $(this).attr('data-rel').replace(/[\?&]pagenum=\d*/g, ''); 

but above link when make alert coming

contents.cfm?up=http%3a%2f%2fmypage.com.com%2fez_9.asp%3frpttype%3d298%26sortby%3d1%26sortorder%3d1%26pagenum%3d3 

but include pagenum, wrong not sure not working

update is: itnenever removes

http://www.example.com/2.asp?na_id=aaa&password=cc&target=ez_9.asp&rpttype=298&action=submit&sortby=1&sortorder=2&pagenum=4&pagenum=-1 

you need decodeuricomponent first before running replace. like:

var urlval = decodeuricomponent($(this).attr('data-rel')).replace(/[\?&]pagenum=\d*/g, ''); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -