Hyperlinks in forum postings open in the same window when target="_blank"

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
5/19/2011 12:38:57 PM
Gravatar
Total Posts 4

Hyperlinks in forum postings open in the same window when target="_blank"

We've had some users notice that when they create a link in a forum post and set the target to "_blank" (i.e. open in a new window) the link will still open in the same window.

This was tested with Firefox 3 & 4, IE 9, and Google Chrome.

We're running mojoportal 2.3.6.4 (one behind the current version), so perhaps this was already fixed in the most recent version?

 

5/19/2011 12:40:54 PM
Gravatar
Total Posts 4

Re: Hyperlinks in forum postings open in the same window when target="_blank"

It looks like the behaviour is the same on this forum, so I'm assuming this is not fixed. The following link has its target set to "_blank" and it opens in the same window.

Test link

5/19/2011 1:12:51 PM
Gravatar
Total Posts 18439

Re: Hyperlinks in forum postings open in the same window when target="_blank"

Hi,

Technically the target attribute is not valid in Xhtml and Html 5. So I think what is happening is that the wysiwyg editor is enforcing valid markup but for some reason they still show the option in the link dialog for this attribute.

The w3c removed this attribute for accessibility/usability reasons, the intention being that users should always be in control and web sites should not open new windows, but leave it under the control of the user whether they want to open a link in a new window. All modern browsers support the ability for users to open a link in a new tab or window, by right clicking or mouse wheel clicking.

In general I agree with the reasoning of the w3c on this but unfortunately a lot of people don't know how to use their web browsers efficiently and have been conditioned by the many sites that do open links in new windows into expecting it to be done for them in some cases. But by doing it we only continue to add to the problem.

My advice would be to not open links in new windows automatically and train users how to open links in a new window themselves, but if a customer insists on it I would implement something in javascript to do it and add it in the master page.

Something like this should do the trick and make all external links open in a new window.

<script type="text/javascript">
$(document).ready(function() {
  $("a[@href^=http]").each(
    function(){
     if(this.href.indexOf(location.hostname) == -1) {
        $(this).attr('target', '_blank');
      }
    }
  )
});
</script>

So, it really isn't a bug per se, other than the editors should probably not show the option for the target since it is not valid. Note however that by adding the target from javascript we are still making the page invalid and it will show as invalid if checked against the w3c validator.

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.