Client.js not loading and page keeps refreshing


#1

Hello,

I have been facing an issue with the Tweet button (and follow button) script on my web app. I get the following error on page load and then the page keeps reloading infinitely.

[12:58:30.482] Error: https://platform.twitter.com/js/tfw/hub/client.js not loaded @ https://platform.twitter.com/widgets.js:1

My app uses iframe to embed my app into websites.
I have tried to remove https, and/or have only http. but nothing helps.

Script im using:

<script type="text/javascript">
 window.twttr = (function (d,s,id) {
  var t, js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
  js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
  return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
}(document, "script", "twitter-wjs"));
</script>
 </code>


Any help would be highly appreciated. 

Thank You
Prerak Mehta

#2

Hi,
Could you tell me the browser you are using?
And if possible do you have any page I could access reproducing that problem?
Thanks


#3

Hey,

I am using Chrome and Firefox (both latest versions).
Sure. So on this page you can sign in on the bottom bar and then click on your display picture or name for a popup to open up. You will see that the popup (an iframe) will keep reloading.
http://incenticity.com/popup.html

Thanks so much
Prerak Mehta


#4

Hey,
The problem is not directly in Twitter’s code, but in your http://rouse.in/popup_demo/client-panel/js/custom/generateUi.js, in the receiver12 event listener, you always change the src of the iframe:
jQuery(’#open_it #rwd_container’).children(‘iframe’).attr(‘src’,newSrc);
And that’s what reloads the content of the iframe.

The message that event handler receives each time the iframe is loaded is a message from our code (to get the URL of the page).
You should ignore messages that are ours. At the first line of your receiver12 just add something like:
if (e.data && e.data.indexOf(‘twttr’) != -1) return;


#5

:smiley: thats great. it worked :slight_smile:

Thanks so much!!
Prerak


#6