开发者

Change title url to external link when using squarespace

开发者 https://www.devze.com 2023-03-10 09:36 出处:网络
I am trying to change the title url of a b开发者_如何转开发log post to an external link when using squarespace? I believe this is possible but I don\'t know the proper code. Any help would be greatly

I am trying to change the title url of a b开发者_如何转开发log post to an external link when using squarespace? I believe this is possible but I don't know the proper code. Any help would be greatly appreciated.


firstly lets create new filter for external links

$.extend($.expr[':'], {
    /**
     * Filter for External links
     *
     * @param element we'll need only DOM Element
     */
    external: function(element) {
        // is it link?
        if (element.tagName.toUpperCase() != 'A') return false;
        // is there href?..
        if (element.getAttribute('href')) {
            // cut off unnecessary
            if ((element.getAttribute('href').indexOf('/') === 0)   // internal link
                || (element.getAttribute('href').indexOf('#') === 0)  // hash
                || (element.getAttribute('href').indexOf(window.location.hostname) === 7) // http://...
                || (element.getAttribute('href').indexOf(window.location.hostname) === 8) // https://...
                    ) {
                return false;
            } else {
                // ya, we've found correct links
                return true;
            }
        } else {
            return false;
        }
    }
});

then....

$function({
  /* All external links */
  $('a:external').each(function(i,e){
    e.attr('title', 'Your Title for External Link :) ');
  }); 
});
0

精彩评论

暂无评论...
验证码 换一张
取 消