With no recent changes to my site, when clicking (or rolling over) the ShareThis icon, javascript errors occur instead of the ShareThis popup appearing. This happens in IE 7 on PC, FF 3.5.4 on PC and Mac and on Safari 4 mac. No differences seem to be made when clearing the cache and inserting the updated button embed code to override the module's.

I tried using the updated code straight from ShareThis.com, but that didn't seem to make a difference either...

Browser/OS(s): Firefox 3.5 (PC & Mac) (w/ updated button code)
Version: Both 6.x-1.x-dev and 6.x-1.6

(when hovering over the button)

shareel is null
Source File: http://w.sharethis.com/button/sharethis.js#publisher=3e6e5018-fef0-4237-b17c-595a95e93007&type=website&button=false
Line: 1

(when clicking on the button -- errors seems to repeat continuously until page refresh)

Error: uncaught exception: [Exception... "Unexpected error arg 0 [nsIDOMWindowInternal.location]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: http://w.sharethis.com/button/sharethis.js#publisher=3e6e5018-fef0-4237-b17c-595a95e93007&type=website&button=false :: anonymous :: line 1"  data: no]

Browser: IE - (w/ and without updated button code on both versions of ShareThis module)

Line: 2, Char: 10750, Error: Object Required, Code: 0

Inconsistently, I get this error, too, in FF:

Error: $try is not defined
Source File: http://w.sharethis.com/share3x/js/mootools-1.2.1-core-nc.js
Line: 1

Comments

pcorbett’s picture

The Safari js error appears as:

Unsafe JavaScript attempt to access frame with URL http://www.zzz.com from frame with URL http://wd.sharethis.com/share3x/lightbox.d8072184e79ed9bb09edfaef9e14524b.html#init/button=false/hash_flag=false/sessionID=1257035452756.91581/fpc=31b0b60-121ebd759d2-502cdd61-26/pUrl=http%253A%252F%252Fwww.zzz.com. Domains, protocols and ports must match.
lucidus_neil’s picture

We are experiencing the exact same thing.

asghar’s picture

Hello

I also facing this problem in fire fox how we can solve this problem?

JacobSingh’s picture

I can confirm this.

Busted for me too.

Thet’s picture

same here.. no solution yet??

Thet’s picture

going back to 1.3-3 seems to be working again.

ChrisRut’s picture

Same here...
:subscribe:

joshfromdallas’s picture

Version: 6.x-1.x-dev » 6.x-1.6

Same Problem,

How do you get 1.3-3 working again? Can someone provide the steps?

otmg’s picture

Component: Code » User interface

same exact problem. suddenly stopped working.

dvness’s picture

I am having the same error occur on two drupal sites that use the sharethis javascript code:
- One site is running on 6.12
- The other site is running on 6.14

tnightingale’s picture

I too am having this error - subscribing

pcorbett’s picture

Priority: Normal » Critical
manoz_79’s picture

I too am having this error - subscribing

awasson’s picture

Yup... Same problem here.

In the interim, I'm just putting the Sharethis code in a block and placing it where I need it.

Anonymous’s picture

Subscribing

glacialheart’s picture

Same thing for me. Subscribing.

geocalleo’s picture

Is this happening to everyone across the board? Using the latest sharethis module? Also, where can I find a previous version so I can downgrade to it?

anon’s picture

Status: Active » Needs review
StatusFileSize
new729 bytes

The problem seems to be that we are missing a wrapping span with an id attribute equals to "sharethis_X" around the link

Example:<span id="sharethis_0">linkhere</span>

This patch is tested in
FF 3.5.7
IE 7
IE 8
Chrome 3.0.195.38

robloach’s picture

Status: Needs review » Fixed

Committed! Wow, that was fun. http://drupal.org/cvs?commit=319890

I'll make a release off of this, close the other issues. This queue is way out of hand and obsolete.

devkinetic’s picture

Status: Fixed » Needs work

I'm still having issues with this after the update, and can confirm that the <span> is there. I created a ticket here filed under the 1.7 release.

http://drupal.org/node/696128

kim.pepper’s picture

Still getting this after updating to 1.7. Chrome reports: "Uncaught TypeError: Cannot read property 'offsetParent' of null"

The only reference to this in share.js is if(shareel.offsetParent){...

I think shareel is not being found, but its incredibly difficult to debug it as its been minified.

Kim

anon’s picture

Hmm, Looks like I just had some luckytime with my patch.

The problem is that the

named "stiframe" isnt included all the time. I having a hard time to find out why.
Mac Clemmens’s picture

[Break on this error] (no source for )
uncaught exception: [Exception... "Unexpected error arg 0 [nsIDOMWindowInternal.location]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: http://w.sharethis.com/button/sharethis.js#ref=jquery&button=false :: anonymous :: line 1" data: no]

I'm getting this error over and over in firebug.

yadranko’s picture

Version: 6.x-1.6 » 6.x-1.7

Same problem here, 6.x-1.6 & 6.x-1.7 both don't work for me.

shawngo’s picture

StatusFileSize
new1.06 KB

I'm getting results where a page with only one ShareThis instance starts at id="sharethis_1" but jquery.sharethis.js is starting at "sharethis_0".

I have a production and stage version of this running - production works but requires patching sharethis/sharethis/jquery.sharethis.js (1.7), stage works just fine.

This patch is just an example of what I had to do to resolve (temporarily).

devkinetic’s picture

interesting that your stage and prod work differently. Is your stage a carbon copy of prod? or is a dev/stage server?

I'd venture to wonder if your module's javascript files are being called in an order that allows it to work on stage, and in a different order on prod.

marcvangend’s picture

Subscribe. I'm seeing the same bug with the 'shareel is null' error, in both 1.7 and the dev version. I tried the patch in #25 on both versions, but it didn't work for me.

Sometimes when loading the page with the dev version I get two identical errors like this:

$try is not defined
http://w.sharethis.com/share3x/js/mootools-1.2.1-core-nc.js
Line 1

Then, when I hover over the ShareThis icon, the scripts start returning this error indefinitely (within seconds, the firebug console shows a few hundred errors and there is no way to stop it other than refreshing the page):

uncaught exception: [Exception... "Unexpected error arg 0 [nsIDOMWindowInternal.location]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: http://w.sharethis.com/button/sharethis.js#publisher=2cb502f4-4233-4a84-8b2c-d213ccacb372&amp;type=website&amp;button=false :: anonymous :: line 1"  data: no]
Line 0
shawngo’s picture

The fact that this did not work in my production environment should have been a big fat red flag. The only difference between the two is the production site has Google Analytics enabled.

What I found was that for some reason everything ShareThis related fails if there are any script blocks outside the head tag (in Firefox (tested ver3.6)).

What I did was, in the Google Analytics settings, selected "Header" in the JAVASCRIPT SCOPE under the ADVANCED OPTIONS.

This still didn't fix the issue since Google Analytics module implements googleanalytics_footer to add any other tracking code.

Here are my updates (sorry no patch) to google_analytics/googleanalytics.module lines 81-94:

    // Custom tracking.
    if (variable_get('googleanalytics_trackadsense', FALSE)) {
      drupal_add_js('window.google_analytics_uacct = ' . drupal_to_js($id) . ';', 'inline', 'header');
    }
    
    googleanalytics_header();
  }
}

/**
 * Implementation of hook_footer() to insert Javascript at the end of the page.
 */
function googleanalytics_header($main = 0) {
  global $user;

  $id = variable_get('googleanalytics_account', '');

I renamed the hook_footer implementation to googleanalytics_header and called googleanalytics_header from the above googleanalytics_init function.

This is possibly the worst solution and I don't recommend. It is only for.. educational porpoises.

Any ideas on how to overcome this issue? I thought I found a similar reference in the forums between ShareThis and GoogleAnalytics.

Shawn

devkinetic’s picture

Great you got it working and thanks for finding that bug.

Obviously, this is not a solution. Plenty of other modules / javascript require script blocks outside of the head. The question is what has changed to the module to instigate this conflict. My gut is telling me its the way/order in which the sharethis javascript is being implemented on the page.

arcaneadam’s picture

Status: Needs work » Needs review
StatusFileSize
new957 bytes

The patch below works, though you may need to change the paths declared in the patch as they were made from my cvs folder.

The problem with the javascript is that it should be adding a span with an id of sharethis_# to all sharethis links. The span id numbers should start at 1 and go up from there. The jquery code that is written loops through the elements but in a loop the i var starts at 0. Simply doing a var a = i + 1; and then using the a var in the id fixes the problem easily.

The attached patch adds that code

sh264’s picture

re:#30
confirming the changes in arcaneadam's patch will work without needing to touch googleanalytics.module
solved for me accross 3 production sites; browsers: ff3.5, ie7/8, chrome (safari); modules: sharethis 6.x-1.7, googleanalytics 6.x-2.2
i like the educational porpoises, wise creatures of the sea.

catch’s picture

Status: Needs review » Reviewed & tested by the community

#30 works for me.

robloach’s picture

Status: Reviewed & tested by the community » Fixed

Committed! Thanks for taking a look at this one.

sh264’s picture

awesome. thanks Rob.

AlexisWilke’s picture

Rob,

You may want to create a version 1.8 since, in effect, 1.7 does not work... I just spent 30 min. trying and all I should have done is take the -dev version!?

And yes, that fix took care of the problem. 8-)

Thank you.
Alexis

robloach’s picture

Version: 6.x-1.7 » 6.x-1.8

Sounds good! :-) ... Thanks a lot for all the tests.

gilgabar’s picture

Status: Fixed » Active

Perhaps there are multiple issues here, but I'm using 1.8 and still getting the error described in the original post: "TypeError: Result of expression 'shareel' [null] is not an object." in Safari and "shareel is null" in Firebug.

AlexisWilke’s picture

gilgabar,

Did you make sure you cleared your server & FF caches? (the server cache, especially if you have boost!)

Thank you.
Alexis

gilgabar’s picture

Yes, cleared caches, but this was a brand new install of the sharethis module anyway, so there should not have been anything to clear.

AlexisWilke’s picture

gilgabar,

Ah! Good point. If it was a new install, it should work as is.

Thinking of it, I used my own code (thinking that maybe the default code could be the culprit.) Could you try with new code from ShareThis to see whether that works?

Thank you.
Alexis

rkdesantos’s picture

The new code fails on at least of my Drupal sites. Even after clearing the cache, etc, the button disappears on the links line, errors in JS, and the settings screen fails to display my customized code for reasons I didn't determine (may be related to FCKeditor showing up rather than just a text box -- however the code still wasn't there if I went to text mode). Have reverted to 1.3.3 again and all is well. Something is still amiss in the JS.

joshfromdallas’s picture

Still doesn't work for me either. I removed the module and uploaded the latest release and still doesn't work. How did you get 1.1.3 to work.

joshfromdallas’s picture

I copied the code from the sharethis site and inserted to test and it works, so looks like something else is going on. Even if I try to download 1.33 or whatever it still doesn't work

How did you guys get the old version to work?

rkdesantos’s picture

@joshfromdallas: make sure you have completely removed and uninstalled the 1.8 version and then upload 1.3.3. (not 1.1!) Clear caches. Obviously any unrelated issues "fixed" since 1.3.3 will return.

jm.federico’s picture

Ok, for ver 1.8 you have to undo patch in #30, which was commited, but guess what, broke everything. So go to jquery.sharethis.js and remove
var a = i + 1;

and change
var wrapper = jQuery('').attr('id', 'sharethis_'+a);
to
var wrapper = jQuery('').attr('id', 'sharethis_'+i);

Federico

robloach’s picture

This is how development here works:

  1. Someone has a problem so they make an issue
  2. Someone creates a patch and uploads it to the issue
  3. People like that patch and set it to "Reviewed and tested by the community"
  4. A maintainer comes along and commits the patch
  5. People dance

If you're not happy with things that are being committed, then please submit a new patch instead of complaining about what is going in. Thanks.

rkdesantos’s picture

@Rob Loach: just who is complaining? Saying something broke isn't a complaint against anyone. It's just describing what happened in that users situation. We're all just trying to exchange information and figure out what works and where the problem(s) are. I imagine that once that happens, someone may step forward with a patch. Until then, we're just trying to deal with a less than perfect situation.

AlexisWilke’s picture

jm.federico,

The old code did not work for me and many others. I'm not too sure why the new code does not work for you, but 1.7 was useless on my end... Did 1.7 work for you as is?

Thank you.
Alexis

robloach’s picture

@rkdesantos Sorry, I was under the impression people were just complaining about things being committed to the module along with noone helping out with a patch. A misconception on my part. Thanks for the explanation.

robloach’s picture

Version: 6.x-1.8 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new9.34 KB

Less features because it moves back to the straight code that ShareThis gives you.

jm.federico’s picture

AlexisWilke

I never tried 1/7, first time I used this modules was with 1.8
Out of the box it didn't work, I then went through the code and saw that the patch in 30 was casing the problem. Right now can't give you much more info except that once I made the change I mention in 45, things worked.

It seems like the only difference between 1.8 and 1.7 is that patch which then confuses me, because it was the patch what was casing me issues.

I can't provide much more info cause I'm not using the module anymore, had some display issued caused by ShareThis itself and not this Drupal module, which made me stop using it.

Hope this helps.

serbanghita’s picture

@jm.federico is kinda right.

I made a checkout of the last version of ShareThis module from the CVS, i went to

/sites/all/modules/sharethis/sharethis/jquery.sharethis.js and changed the line:
var wrapper = jQuery('<span></span>').attr('id', 'sharethis_'+a); into
var wrapper = jQuery('<span></span>').attr('id', 'sharethis_'+i);
But only works in Firefox.

Then i have downloaded http://ftp.drupal.org/files/projects/sharethis-6.x-1.7.tar.gz and kept the above change to /sites/all/modules/sharethis/sharethis/jquery.sharethis.js and worked in all browsers!

BrockBoland’s picture

I have a View listing the teaser for several blog posts, with a ShareThis link next to each one. Right now, I'm doing all my testing on a Mac - haven't fired up the virtual machine to try this in Windows yet.

In Firefox, 1.8 and the current -dev both fail on the first item in the list, but work on the others. If I revert the change to the ID on that span - as serbanghita describes in #52 - then that bug goes away. This bug was also affecting the node view; since there is only one ShareThis link when viewing a node, then the first ShareThis link wasn't working, it would not work on that page. It only worked on ShareThis links that were NOT the first on the page.

However, that doesn't solve the problem completely. After making that change, it works every time in Firefox, but in Safari and Chrome, it's hit and miss: sometimes every ShareThis link works, sometimes none do. I've been checking the links, doing a hard refresh, checking again, and so on, and it seems to fail about 2 times out of 3.

This leads me to suspect a race condition. It seems like the JS is trying to assign that functionality to the links before the ShareThis code is pulled in from their server - though if I understand the code correctly, that's what the sharethisQueue variable is there to handle (right?).

Anyway, I haven't had any luck yet, but I hope this helps move someone a step forward.

AlexisWilke’s picture

Hi Brock,

I have a link near the bottom of this page:

http://linux.m2osw.com/drupal

Is it working for you, or not? (the page may be loading a little slow as it is on my DSL)

It works great for me in SeaMonkey & FireFox under Linux (I rarely use IE, only to test Customers websites...)

Thank you.
Alexis Wilke

BrockBoland’s picture

Alexis - looks good in Safari, Chrome, and FF Mac. I refreshed a couple times to be sure.

rkdesantos’s picture

Sounds like v1.8 + #52 + solution to the possible race condition described in #53 and we are almost there.

BrockBoland’s picture

#52 actually rolls back the one change from 1.7 to 1.8, so really:

1.7 + solution to the possible race condition described in #53

But, still haven't figured out whether it really is a race condition or not.

robloach’s picture

If someone either reviews that patch and sets the issue to RTBC, or uploads a new patch that gets RTBCed, I'd be more than happy to commit it.

AlexisWilke’s picture

Well... this is weird, isn't it?!

I'm running with 1.8 and it works just fine for BrockBoland off of my server. Yet, we are saying here that the problem is in the JavaScript and thus due to the client, not my server. And if version 1.8 is really the problem, then it should fail on his computer browser.

So a race condition possibly, or a conflict with another module!

I'll have a look to the JS again...

Thank you.
Alexis

AlexisWilke’s picture

Could that be it?

You include the JavaScript from sharethis.com after the Drupal module sharethis code. For those with a problem, could you try to move the first two drupal_add_js() calls after the if() block and report whether that helps at all?

function sharethis_add_js() {
	// Be sure to add the ShareThis header code only once.
  static $sharethis_added = FALSE;
  if ($sharethis_added === FALSE) {
  	// Adds the ShareThis jQuery plugin as well as the related Drupal JavaScript behavior and CSS.
  	$path = drupal_get_path('module', 'sharethis');
    drupal_add_js($path . '/sharethis/jquery.sharethis.js');
    drupal_add_js($path . '/sharethis.js');

    // Add the ShareThis code if desired.
    $code = variable_get('sharethis_code', '');
    if (!empty($code)) {
      $code = str_replace('<script type="text/javascript" src="', '', $code);
      $code = str_replace('"></script>', '', $code);
      drupal_add_js(array('sharethisUrl' => $code), 'setting');
    }

    // Flag that the JavaScript has been registered.
    $sharethis_added = TRUE;
  }
}

Now... What is that 'true' in the following if() condition?! Is that some debug left over? Or is it because we want to create a new button for each teaser entry?

    [...]

    // Set a kill switch so that the API isn't loaded twice.
    if (jQuery.fn.sharethis.loaded || true) {
      jQuery.fn.sharethis.loaded = false;

    [...]

Thank you.
Alexis

psykomf’s picture

I am using 1.8 and I get the "Shareel is null" error on the first sharethis icon that shows on the page. All subsequent icon's work correctly with no error message.

The best fix for this seems to be uninstalling 1.8, installing 1.7 and going through step #53?

psykomf’s picture

I was actually able to get 1.8 working correctly by changing this line in jquery.sharethis.js

var a = i + 1;

to var a = i;

AlexisWilke’s picture

psykomf,

Did you try what I suggest in #60 ?

Thank you.
Alexis

werushka’s picture

hi AlexisWilke I am also getting the same problem, from your #60 i tried your solution to move the drupal_add_js s after if but which one? I tried couple of variations but still couldn't figure out. Could you please point out?

AlexisWilke’s picture

Werushka,

I do not know whether that would work, but it seems to make sense that the Drupal JS should be included after the Share This JS. Now, looking at the code closer, it won't matter since Drupal will anyway include those JS in the header. We may need to add them to the footer instead or inline.

It would have been like this:

function sharethis_add_js() {
    // Be sure to add the ShareThis header code only once.
  static $sharethis_added = FALSE;
  if ($sharethis_added === FALSE) {
    // Adds the ShareThis jQuery plugin as well as the related Drupal JavaScript behavior and CSS.
    $path = drupal_get_path('module', 'sharethis');

    // Add the ShareThis code if desired.
    $code = variable_get('sharethis_code', '');
    if (!empty($code)) {
      $code = str_replace('<script type="text/javascript" src="', '', $code);
      $code = str_replace('"></script>', '', $code);
      drupal_add_js(array('sharethisUrl' => $code), 'setting');
    }

// MOVED .js ADD...
    drupal_add_js($path . '/sharethis/jquery.sharethis.js');
    drupal_add_js($path . '/sharethis.js');


    // Flag that the JavaScript has been registered.
    $sharethis_added = TRUE;
  }
}

But we may actually need to also change the drupal_add_js() call like this:

  drupal_add_js($path . '/sharethis/jquery.sharethis.js', 'module', 'footer');
  drupal_add_js($path . '/sharethis.js', 'module', 'footer');

In this case, they can appear before or after the if(), it shouldn't matter.

Btw, if it works as I'm thinking it should, then the fix in 1.8 should also be removed... (it seems to me). Thus, testing 1.7 and 1.8 with this fix, 1.8 shouldn't work.

Thank you.
Alexis

Mac Clemmens’s picture

StatusFileSize
new72.33 KB

Hi Alexis,

I tried #65 and it didn't work.

Checking the firebug log, I get the following errors:

shareel is null

[Break on this error] ST_JSON=new function(){this.encode=fun...bj=SHARETHIS.addEntry()}}catch(err){};
sharet...n=false (line 1)
uncaught exception: [Exception... "Unexpected error arg 0 [nsIDOMWindowInternal.location]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: http://w.sharethis.com/button/sharethis.js#publisher=ae9b6ac6-092d-466c-... :: anonymous :: line 1" data: no]

When I move the script to the footer, I get a lot of errors. I've attached the error log from firebug.

I just wrote my own module to do it and I had no problems. I just basically plopped the sharethis code right into the link area. Is this simpler approach possible?


function dd_sharethis_link($type, $object, $teaser = FALSE) {
  $links = array();
  if ($type == 'node' && ! $teaser) {
    $links['dd_share_this'] = array(
      'title' => '<script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=ae9e6ac6-093d-466c-95db-0ca8cad75d27&amp;type=website&amp;style=rotate"></script>',
      'html' => TRUE,
    );
  }
  return $links;
}

AlexisWilke’s picture

@Digital Deployment,

Today I got a surprise! I was working on the ladybug theme, when I went to my Linux Geek page...

Somehow, the page would load, just fine, and then start running the JavaScript code loaded by AJAX by this module and kaboom! A nice WSOD. But for once, a JavaScript WSOD. The result with a completely empty page. I tried with Chrome and that worked. But SeaMonkey and FireFox both failed at that point.

The failure happens in the ShareThis code loaded by AJAX, but I'm not too sure why that would be.

Then I tried your solution with just putting a <script> tag and the necessary URL and it worked like a charm...

I'm not too sure where the problem lies. It could be too old a version of the sharethis/*.js library?

Thank you.
Alexis

scottsawyer’s picture

This worked great for me!! Thank you, thank you.

Tested FF 3.5, Chrome on Winders 7

tomotomo’s picture

For those who are saying this is fixed, what browsers are you testing in? And do you have theme devel on?

dboulet’s picture

In my case, 1.7 works fine, 1.8 does not. I was getting "Uncaught TypeError: Cannot read property 'offsetParent' of null" in Chrome with 1.8.

dafeder’s picture

So, I finally got this working by downloading this latest dev version and applying the patch in #30 in REVERSE. I imagine this would work on 1.8 as well. DL the patch into your modules/sharethis folder, and do:

patch -p2 -R < jquery.sharethis.js__1.patch

kyoder’s picture

it appears that the patch from #30 has been applied which is great except it seems that now i needs to start at 0 and not at 1
so that part of the patch "a = i +1" breaks the current 6.x version of the module

so to fix simply set a = i

altrugon’s picture

I had to use #72 for version 6.x-1.8

altrugon’s picture

StatusFileSize
new565 bytes

Here is a patch for comment #73:

avpaderno’s picture

Status: Needs review » Closed (outdated)

I am closing this issue, as Drupal 6 is no longer supported. Please re-open it if the issue is still relevant for the Drupal 7 or 8 version of the module.