The great ”Sites I’m following” battle

Spoiler: It’s a draw.

The problem

A customer has a server setup where the URL for the default zone is not accessible at all for users (has something to do with ADFS). This is working out somewhat fine, except in a few places. Some links are rendered with urls point to the default zone, meaning that they redirect the users to the wrong domain. Some of these links are located on *queue horror music* the ”sites I’m following” page.

sites I'm following

The circled link leads to the default URL, in this solution only accessible from inside the server. So every user using this page will get redirected to a page that doesn’t work.


It started out with a good solution of an HTTP handler, but because of circumstances, that was not a viable solution. Instead I had to resort to fixing it on the client side with JavaScript.

Attempt one

I wanted something that wasn’t too problematic performance, so I added a click handler to all the anchor tags in question. When a user clicked a links, the href attribute was replaced to contain the correct hostname.

This uses a configuration object where a specific hostname was matched to another. I will not publish it here, since it contains the actual domains, but it looks something like this:

Does it work? No.

Why? Well, it works on all links except the ones on the ”Sites I’m following” page. The hrefs are replaced, but just before the users is redirected (visible in the next image, circled in blue), it is changed back to the original URL. Makes me pull my hair. SharePoint runs some kind of magic (probably something to do with mquery) after my click handler.

Solution 2

So then I started looking at the visible url, can I somehow change it? Turns out it’s an input field with a value. Circled in red here:

sites I'm following-htmlI can easily enough change the value, and I did. But when run on page load it didn’t happen. However, when I ran the exact same code in the browser directly, it worked. Until I resized the window. I’m not even kidding. Every time I resize the window, the value of each input field is reset back to its original value. I have no idea why someone put that in there from the beginning.

Solution 3

In the end I just replaced the anchor tag and input field with my own. Stupid.


E-postadressen publiceras inte. Obligatoriska fält är märkta *