TechLife
TechLife

Reputation: 183

IE11 not able to get the the current URL using document.location.href OR $(location).attr("href")

I have to add an anchor tag which when clicked reloads the current page (anchor tag contains the current url)

document.getElementById('clickhere').innerHTML='<div>Something went Wrong! <a href=""'+$(location).attr("href")+'>Click here to reload</a> </div>';

When I click on the anchor tag in chrome, the page loads fine. As per the screenshot when I hover over the link, it shows the full URL. After /private I am able to see the other part of URL.

enter image description here

Below screenshot when I executed the page in IE11. If I check, the part after /private is not present.

enter image description here

I am not able to get why the difference. I have added this code in the Jquery AJAX success section. Also tried using Javascript's document.location.href but still the same problem.

Upvotes: 0

Views: 1302

Answers (2)

vinod joshi
vinod joshi

Reputation: 90

enter image description here

click active x control button and your script is load and you can use both line work

1- document.getElementById('clickhere').innerHTML='Something went Wrong! Click here to reload ';

2- $('#clickhere').html('Something went Wrong! Click here to reload ');

Upvotes: 0

Andrew Nguyen Vo
Andrew Nguyen Vo

Reputation: 131

Could you try with:

windows.location.href

document.getElementById('clickhere').innerHTML='<div>Something went Wrong! <a href="' + window.location.href + '">Click here to reload</a> </div>';
<div id='clickhere'></div>

Upvotes: 1

Related Questions