How to add nofollow to this script, and add "url" before links

Discussion in 'JavaScript' started by farooqwani, Apr 13, 2013.

  1. #1
    Hi,

    This is a helper script which makes opening url in new window possible. I will like to add nofollow tag to the links this script opens.

    Also, i will like to add www .yoursite.com/redirect.php before the link this script opens. Like this : www .yoursite.com/redirect.php?url=www .yoursite.com

    Here is the script :

    // ------------------------------------------------------------------------
     
    /**
    * Anchor Link - Pop-up version
    *
    * Creates an anchor based on the local URL. The link
    * opens a new window based on the attributes specified.
    *
    * @access    public
    * @param    string    the URL
    * @param    string    the link title
    * @param    mixed    any attributes
    * @return    string
    */
    if ( ! function_exists('anchor_popup'))
    {
        function anchor_popup($uri = '', $title = '', $attributes = FALSE)
        {
            $title = (string) $title;
     
            $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
     
            if ($title == '')
            {
                $title = $site_url;
            }
     
            if ($attributes === FALSE)
            {
                return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
            }
     
            if ( ! is_array($attributes))
            {
                $attributes = array();
            }
     
            foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
            {
                $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
                unset($attributes[$key]);
            }
     
            if ($attributes != '')
            {
                $attributes = _parse_attributes($attributes);
            }
     
            return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
        }
    }
    Code (markup):
    Which in turn works with :

    ' . anchor_popup('gtellart/go/'.$l->linkID, $l->link_title) . '
    Code (markup):
    I will appreciate the help.

    Thanks.
     
    farooqwani, Apr 13, 2013 IP