Can't set href with .attr()

Viewed 134

Edit: It was a Firefox-only problem related to the addon Adblock Plus. Reinstalling the addon put an end to this weird behavior on which URLs with some specific special characters would make anchors disappear altogether.

How do I attribute URLs with specials characters to a href using jQuery?

What I'm doing right now is:

var x = encodeURI(myURLhere)

Which I know generates valid links, because I've been using console.log(x) to check it.

But when I do:

$("#tweet").attr("href", x);

My anchor simply disappears.

One example of an URL on which that happens:

https://twitter.com/intent/tweet?text=%22If%20it%20is%20not%20right%20do%20not%20do%20it;%20if%20it%20is%20not%20true%20do%20not%20say%20it.%22%20%E2%80%93%20Marcus%20Aurelius

Does anyone have any suggestion as of what I can do to attribute such URL to my anchor's href?

1 Answers
Related