user1973900
user1973900

Reputation: 381

html, url, pass credentials, relative path

I want to logout from HTTP basic Authentication at request (before browser is closed), so reading on net, the only way is to pass some wrong credentials to server. It work but when I tried with relative path is disaster :)

I use

<a href="[email protected]" >Logout</a>

But the url is

http://10.10.0.71/[email protected] 

instead of

http://[email protected]/index.htm 

How can I solve this?

Upvotes: 1

Views: 1450

Answers (1)

Mooseman
Mooseman

Reputation: 18891

Generate the full URL with JS and link to it:

<script>
function logoutLink(str) {
  document.getElementById("logoutlink").src="http://logout@"+window.location.host+"/index.htm";
}
</script>
<a id="logoutlink" href="#">Logout</a>

Demo: http://jsfiddle.net/9XSYq/ (Doesn't work very well in a fiddle because of their iframe.)

Upvotes: 2

Related Questions