I'm trying to dynamically swap the url I want my users to tweet. I
have a video player with a url of www.domain.com/video. My tweet
button is located on this page. My videos each have their own url
which I use to view them in the player. Using javascript, as each
video is played I add the url of the video into the anchor tag with
docGetById('myID').setAttribute('data-url','MyVideoUrl'). Instead
twitter uses the current url with location.href if the data-url isn't
genuinely coded onto the page. (See my code sample below)

What seems to be happening is twitter doesn't see my changes with
javascript. The actual url needs to be physically coded into the
anchor tag rather than dynamically added by javascript. I've tried
having my javascript execute before & after twitter.js, but no matter
what I do it only works when I have the url physically hardcoded into
the anchor tag. I've also tried writing the twitter anchor tag onto
the page, before widget.js with the desired url coded in. No luck.

Sample Code:

<a id="myId" href="http://twitter.com/share"; data-text=""
style="height:35" data-count="horizontal" data-related="myRelated"
class="twitter-share-button">Tweet</a>  <---Data-url to be added with


If the url to be liked isn't coded into the html of the anchor tag
twitter uses the current browser location with location.href, rather
then my javascript which is swapping the url to be liked in the anchor
tag for the current video being played. (My Page will not refresh)


While remaining on a single page, how can I swap the url to be
(I may need to make changes to twitter.js and host it on my server):
Is there an uncompressed, readable version of widget.js? Can I be
provided a link to it?
Is there any long-term negatives to hosting widget.js on my server
rather than have the.src point to platform.twitter.com?

Twitter developer documentation and resources: https://dev.twitter.com/doc
API updates via Twitter: https://twitter.com/twitterapi
Issues/Enhancements Tracker: https://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 

Reply via email to