Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update of `anchor_popup` function to let it build some accessible links ... #1012

Closed
wants to merge 1 commit into from

3 participants

Pierre Cassat (aka pierowbmstr) André Silva Andrey Andreev
Pierre Cassat (aka pierowbmstr)

Just some few changes:

  • replace the javascript:void(0) instruction by the URL for the href attribute,
  • add a target=_blank attribute,
  • add a return false instruction to the end of the onclick attribute.

This way, if the browser can execute JS the popup will be open just as usual, and if it doesn't a new window will be open ...

Pierre Cassat (aka pierowbmstr) piwi Update of `anchor_popup` function to let it build some accessible lin…
…ks ...


Just some few changes:
-   replace the `javascript:void(0)` instruction by the URL for the `href` attribute,
-   add a `target=_blank` attribute,
-   add a `return false` instruction to the end of the `onclick` attribute.

This way, if the browser can execute JS the popup will be open just as usual, and if it doesn't a new window will be open ...
317fdb7
André Silva

I was about to suggest this, but I'm glad I'm not the only one who cares about this issue. The link become more accessible if the href attribute is correctly populated with the URL. It's also very easy to fix, while granting more benefits to users.

Andrey Andreev
Owner

The target attribute is not allowed in XHTML 1.0 Strict.

Andrey Andreev
Owner

... and with that said, I just made the other changes: 81c3208

You can still pass a "target" attribute, if you need it.

Andrey Andreev narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 4, 2012
  1. Pierre Cassat (aka pierowbmstr)

    Update of `anchor_popup` function to let it build some accessible lin…

    piwi authored
    …ks ...
    
    
    Just some few changes:
    -   replace the `javascript:void(0)` instruction by the URL for the `href` attribute,
    -   add a `target=_blank` attribute,
    -   add a `return false` instruction to the end of the `onclick` attribute.
    
    This way, if the browser can execute JS the popup will be open just as usual, and if it doesn't a new window will be open ...
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 system/helpers/url_helper.php
4 system/helpers/url_helper.php
View
@@ -207,7 +207,7 @@ function anchor_popup($uri = '', $title = '', $attributes = FALSE)
if ($attributes === FALSE)
{
- return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
+ return "<a href='".$site_url."' target='_blank' onclick=\"window.open('".$site_url."', '_blank'); return false;\">".$title."</a>";
}
if ( ! is_array($attributes))
@@ -226,7 +226,7 @@ function anchor_popup($uri = '', $title = '', $attributes = FALSE)
$attributes = _parse_attributes($attributes);
}
- return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
+ return "<a href='".$site_url."' target='_blank' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."'); return false;\"$attributes>".$title."</a>";
}
}
Something went wrong with that request. Please try again.