I'm adding some social share links to a site. In the HTML, I just have basic links like:
<a class="facebook_share" href="https://www.facebook.com/sharer/sharer.php">Facebook</a>
I'm using jQuery 1.10.1 to append parameters (current page url and, for some social networks, the current page title) to the link href. Here's an example:
jQuery(document).ready(function($) {
"use strict";
var $title = $(this).attr('title');
var $href = $(location).attr('href');
// Facebook
var fb_url = $("a.facebook_share").attr("href");
$("a.facebook_share").attr("href", fb_url + "?u=" + encodeURIComponent($href)); // add encoded version of current page href to FB url
});
In IE7, I'm getting "error on page" as follows: Line: 0 Char: 0 Error: Script error Code: 0
So in IE7, the parameters don't get added to the link href.
Chrome, F'fox are OK. IE8 is OK now I'm testing on public server but was giving "line 5: object doesn't support this property or method" when I was testing on my local WAMP server.
Test page with links to 4 networks here: