tl;dr Contact Sitecore Support, mention ticket number 441249 and install the update package they send you.
I originally noticed this bug in Sitecore 8 update 2 (rev 150223). Unfortunately due to being too busy I didn’t have time to blog it. A conversation on twitter earlier today I noticed other blog posts on the same issue, but they did not provide a full fix for the issue. As far as I can tell from the release notes this is still an issue in Update 5 (the current version), but I haven’t tested or confirmed this.
We have a several templates with General Link fields on. The options for the Target droplist presents: Active Browser, Custom and New Window. There is no option not to select something, Active Window is selected by default.
The rendered HTML on the front-end also seems to render “Active Browser” and not _top or _self as I would have expected. Unfortunately since those are not valid anchor target values the link opens in a new window (named “Active Browser”, that’s what the target is meant for…)
Switching to raw values also confirms this:
I tried adding in a new entry in
/sitecore/client/Applications/Dialogs/InsertLinkViaTreeDialog/PageSettings/Targets but although this added the option in the dropdown, it looks like the control uses the displayname and not the Text field of the template.
This seems to be a Sitecore 8 bug since it is working fine in Sitecore 7.5, which also has the option not to select anything (an empty window). The options presented also seem to follow valid html options, e.g. _self, _blank etc.
The only manual fix for this was to switch to raw values mode to delete the target attribute, which fixes the issue until the editor edits the field again.
No errors were shown in the logs and we had 2 separate projects both on Sitecore 8, update 2 and both with the same issue.
A support ticket was raised with Sitecore and they provided the following fix:
- Navigate to the following item in the Core database in the Content Editor:
- Replace the value in the Root field of the Filters section with the following, and save changes:
/sitecore/client/Business Component Library/System/Texts/Targets
Switching back to the master database and checking your General Link field the options look more like the ones we were expecting.
The links then render correctly on the front-end (i.e. without any target attribute) and they do not open in a new window. Note there is also now an “empty” default option. Job done… but not quite.
The Full Fix
Unfortunately, that’s only a half fix. Although the links now render correctly the insert link dialog no longer remember your previous option. This is similar to the issues in earlier versions of Sitecore 7, but that was much worse since it did no remember any part of your link selection, at least here it is just the target option:
InsertLinkViaTreeDialog to reference these files. This is all wrapped up in an support package that can be deployed using the installation wizard, and also contains changes from the initial fix.
You can request the update package from Sitecore Support and mention ticket number 441249. This should be rolled into a future update.
Thanks to Sitecore Support in helping resolve the issue.
Updating Existing Content
Even though we were in a development phase, and not a live site, we still had a lot of content since sections of the site were being populated as we completed them. Unfortunately the fix does not revert or fix any existing content you may have created and they will continue to render with target=”Active Browser” since it’s in the raw values. The fix is to open the Insert Link dialog and save again.
But we had a lot of content. Doing this manually was either going to take a long time or something was going to get missed.
The easiest solution I could think of was to use Sitecore Rocks to run a simple search and replace:
Rocks won’t let you run the query to replace with empty, so enter anything into the
Replace With field, switch to the script tab and update the
replace "target='Active Browser'" with "" from /#sitecore#/#content#//*
If you dont have Visual Studio installed, then remember there is a desktop version of Sitecore Rocks that you can install on the server (and yes, it’s the same version as the VS plugin – remember to use the Hard Rock Service).