-1

I am creating table using for loop and in each loop making the text as url as below:

txt_2 += "<td> <a href=\"" + urlString + "/\">" + "Sample" + "</a></td>"; 

On clicking the original URL it downloads one file from AWS but when I click on this text 'Sample' on the page, this URL is having amp; where attributes are concatenated at & character, due to which on click the 'Sample' text it is giving an error and not downloading the file

From page: https://test.s3.us-west-1.amazonaws.com/Sample?AWSAccessKeyId=XYZ&amp;Expires=1534955149&amp;Signature=ababa

Original: https://test.s3.us-west-1.amazonaws.com/Sample?AWSAccessKeyId=XYZ&Expires=1534955149&Signature=ababa

I used below code to do the job in code(home.html) but when inspecting the element on the browser it shows me amp; again.

var urlString = url.replace(/&amp;/g, '&');

Can i avoid URL to have amp; from the page?

CodeQuestor
  • 881
  • 1
  • 11
  • 25

1 Answers1

0

Just look at the answer here:

Decode &amp; back to & in JavaScript

This is a robust solution as it will tackle any problem with HTML entities.

enf0rcer
  • 545
  • 2
  • 11