user838838
user838838

Reputation:

how to remove a part of a url from a url using jquery?

I have a javascript variable

var url =  http://www.abc.it/it/security/security.aspx?security=pdfcompare&../securitycomparepdf/default.aspx?SecurityTokenList=blab]2]0]blab$ALL|blab]2]0]blab$ALL|blab]2]0]blab$ALL;

I need to remove the part "../securitycomparepdf/default.aspx?" from it using jquery, so that the variable becomes

http://www.abc.it/it/security/security.aspx?security=pdfcompare&SecurityTokenList=blab]2]0]blab$ALL|blab]2]0]blab$ALL|blab]2]0]blab$ALL;

Can someone please suggest?

Thanks

Upvotes: 0

Views: 2936

Answers (2)

neworld
neworld

Reputation: 7793

Made a demo for you: http://jsfiddle.net/B3Uwj/27/ (from @tats_innit)

url = url.replace("../securitycomparepdf/default.aspx?", "");

Upvotes: 1

jacktheripper
jacktheripper

Reputation: 14219

Use the following JS

var url = "http://www.abc.it/it/security/security.aspx?security=pdfcompare&../securitycomparepdf/default.aspx?SecurityTokenList=blab]2]0]blab$ALL|blab]2]0]blab$ALL|blab]2]0]blab$ALL";

url = url.replace("../securitycomparepdf/default.aspx?","");

​alert(url);​

See a live example here

Upvotes: 1

Related Questions