Reputation: 69993
I was going through a website I've taken over and came across this section in one of the pages:
<a href="javascript:window.location='<%=GetSignOutUrl()%>';">
// img
</a>
Apparently anyone who has ever used the site without javascript would not be able to log out properly (surprisingly enough, this has never come up).
So the first thing that comes to mind is
<a href="<%=GetSignOutUrl()" onclick="javascript:window.location='<%=GetSignOutUrl()%>';">
// img
</a>
Then I realized I don't know why I'm keeping the javascript call around at all. I'm just a little confused as to why it would have been written like that in the first place when a regular link would have worked just fine. What benefit does window.location have over just a regular link?
This is also the only place in the website I've seen something like this done (so far).
Edit: The programmer before me was highly competent, which is actually why I was wondering if there was something I wasn't taking into account or if he just made a simple oversight.
Upvotes: 8
Views: 629
Reputation: 1159
There are three possibilites:
I would remove it and see if it breaks. But then again, I'm a conformist.
Upvotes: 3
Reputation: 42185
My guess is that if the developer didn't know to consider the client's capability of executing javascript, they might not have known what a href is. It's unlikely but not impossible.
Upvotes: 1
Reputation: 1715
It could be because multiple domains possibly are used and which one was unclear or not easily available in the code?
Upvotes: 0