2013-04-07 58 views
0

我想从HTTP基本身份验证请求(在浏览器关闭之前)注销,因此在网上阅读,唯一的方法是将一些错误的凭据传递给服务器。它工作,但是当我试图用相对路径是灾难:)html,url,pass证书,相对路径

我用

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

但是URL是

http://10.10.0.71/[email protected] 

,而不是

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

我该如何解决这个?

+0

不要使用HTTP认证 – Mooseman 2013-04-07 20:13:13

+0

也许你可以用JavaScript来做到这一点; 'onclick =“window.href = \”http://[email protected]/index.htm \“; return false;”' – 2013-04-07 20:14:12

+0

@Mooseman - >它是一个嵌入式设备:) – user1973900 2013-04-07 20:17:47

回答

2

生成完整的URL与JS并链接到它:

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

演示:http://jsfiddle.net/9XSYq/(不以小提琴很好地工作,因为他们的iframe的)

+0

我不知道IP!它是动态的:)但我可能会尝试找到alert(document.URL); – user1973900 2013-04-07 20:24:39

+0

@ user1973900编辑:) – Mooseman 2013-04-07 20:54:37

+0

非常感谢您的努力。我解决它类似window.open('http://[email protected]'+window.location.host,'_self'); – user1973900 2013-04-07 21:19:26