ID:1925994
 
Resolved
The browser control is better equipped to handle dynamically created links.
BYOND Version:508.1298
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Chrome 45.0.2454.78
Applies to:Webclient
Status: Resolved (509.1307)

This issue has been resolved.
Descriptive Problem Summary:
Interface links (a href='?_src_=' type links) will randomly open up in a new tab.

I haven't been able to figure out why or when or how.

I thought they might have a target= set, but it would seem not. I do know that it's consistent to what browse() windows it happens to, the player panel overview will do it, viewvariables will do it, but player panel's player details window won't. the windows it happens to it happens to all links in the window (and vice-versa)


If you want to test this out with /tg/station code (since you are already downloading our code to test the map control bug) Just set yourself to an admin in config/admins.txt (just add the line lummoxjr = host) and play around with the following admin tools:

Player panel verb (admin tab):
Click vv on yourself to open a list of every variable on your mob (new tab opens, vv opens up on original tab)
Click pp (player panel) on yourself to open your player panel details page (new tab opens, pp opens up on original tab)
in your player panel details page, click VV to open up your variable page (same as on the player panel overview) (no new tab)

If you inspect the elements you will notice that the VV link in both player panel overview and player panel details are identical.

(also happens in firefox)

This has been happening since 1295 at the earliest.
Bump, still happening in 1306
Ah, I bet it's not detecting the URL case of starting with a question mark. I'll add something for that.
Wouldn't it be safer to just always use the byond:// protocol?
Yes, it would be safer. However back when I first wrote about using links in output, I noted that in browser controls it's required, but in output it isn't, even though it's best practice to always use the protocol. The webclient has to contend with games that assume they're using a regular output control.
Super Saiyan X wrote:
Wouldn't it be safer to just always use the byond:// protocol?

I mean, we aren't going to be targeting the webclient with how we program, generally speaking it will become a nice to have thing we reserve for byond members to play with (since it would allow them to use tablets), while still recommending seeker for the client.

Lummox JR wrote:
Ah, I bet it's not detecting the URL case of starting with a question mark. I'll add something for that.

I don't think that's it. it seems to happen to all links in certain windows, rather certain links in all windows.

I do know that a few of the browse() windows have embedded dom altering javascript. So that might be it.
In response to MrStonedOne
MrStonedOne wrote:
I don't think that's it. it seems to happen to all links in certain windows, rather certain links in all windows.

I do know that a few of the browse() windows have embedded dom altering javascript. So that might be it.

Oh, you're only talking about browser windows, not output?

DOM alteration is something that the webclient unfortunately can't properly account for--not without a timer or something that tries to look for changes. If your code alters the DOM to insert links, then you must account for it yourself. This should do the trick in your JavaScript:

if(window.byond && window.byond.parseLinks) window.byond.parseLinks()

That will re-invoke the inserted code that checked for links in the first place, and reformatted them properly.

If you know of any more-or-less foolproof way of detecting DOM changes and responding to them in a timely manner, I'd be delighted to work that into the inserted JS and solve this problem once and for all.
I found a solution to the problem of dynamically created links and forms.

It is not 100% perfect, because if you do something like change the href on an existing link it won't work. But detecting links that are newly created is now handled.
Lummox JR resolved issue with message:
The browser control is better equipped to handle dynamically created links.