'Why is my domain prefixed to the value of href of <a> and/or the url of window.Open()
Every so often (1/20) I use to have issues with the href
value of a hyperlink being prefixed with my domain. Same goes for the url of window.open()
.
For example:
<a href="http://www.SomeURL.com" target="_blank">someURL</a>
OR
window.Open('http://www.SomeURL.com', '', '');
would open up a new browser tab and give me a 404 with the requested url of:
http://www.myDomain.com/http://www.SomeURL.com
As a work-around, I have my 404 error page get the requested url and if the requested url contains http://www.myDomain, I slice it then try to redirect again without my domain prefixed. I am guessing there is an actual solution to this though?
additional info
I have a gridView that list activities- some fields being: name, address, website ...etc. I use jQuery to get the URL of the gridView row that was clicked. I then insert that URL into a hyperlink inside of a span that is already on my page.
jQuery
var str = $("td:last", this).text();
$ ("#urlInfoLocation").html('< a id="urlLocation" target="_blank" href="' + str + '">' + str + '');
the span that is already on my page
< span id="urlInfo">
Solution 1:[1]
Another reason is you entered a unicode Right or Left Double Quotation Mark. Here's an example I found in my own page"
<a href=”https://www.youtube.com/watch?v=txLrNhv8GW0”>Q&A on Zone 2 Exercise with Peter Attia, M.D.
Just replace with a normal double quote.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Todd Hoff |