Problem with location.href in widgets.js when using IE


#1

I’m working on adding some Twitter Tweet buttons to a page, and I need to make sure that Twitter scripts are loaded after the window Load event. I am doing this by creating document fragments and appending them to the DOM for performance reasons.

The issue is that in IE8/9, something breaks if you navigate between pages via anchor links - any reference to ‘location.href’ in the Twitter widgets.js will return ‘Unexpected call to method or property access’. If you use ‘window.location.href’ the property is defined and there is no issue. I can work around this by either not loading Twitter on the Load event or by not using document fragments, but I’d prefer not to go down either of those paths.

Is there another workaround I’m missing? Is it possible for Twitter to use the full property ‘window.location.href’ instead of the shorter alias so there are no issues with IE?

I’ve attached an image to show that I’m not crazy:


#2