0

I have this button made in javascript and when it is clicked it opens up a small twitter popup window that allows the user to follow me. Now what I want is for this popup window to close once the person clicks "Follow". I have attached a picture of the popup window so you can get more of an idea. Here is the script for that window that i'm trying to modify.

<script type="text/javascript" charset="utf-8">

window.onload=function(){ 
twttr.events.bind('follow', function(event) {
    var followed_user_id = event.data.user_id;
    var followed_screen_name = event.data.screen_name;
    //alert('you have followed " '+followed_screen_name+'"');// Uncomment it for the javascript popup to activate
    document.getElementById('download').style.display = 'block';
});


twttr.events.bind('unfollow', function(event) {
    //alert('Unfollowed now'); // Uncomment it for the javascript popup to activate
    document.getElementById('download').style.display = 'none';
});

}
</script>

I don't know how or where to insert the code that makes it close once the follow button is clicked. If you are familiar with this situation I would greatly appreciate any information whatsoever. Thanks in advance :)

  • ok, so if you uncomment the `alert` in the first function, is that pretty much where you want to close the window? What if you replace that with `window.close();`? Try that, and let me know if that works for you. –  Mar 29 '15 at 02:22
  • when you said "uncomment the alert" do you mean remove the "//alert" along with the whole line or did you mean remove just the "//alert"? – Scorey Smith Mar 29 '15 at 02:34
  • Is the `alert` exactly where you want the window to close? –  Mar 29 '15 at 02:35
  • I think that's where I want it xD. I mean at this moment are there any other places I can put it? – Scorey Smith Mar 29 '15 at 02:41
  • That's why I said uncomment it. If the alert box is popping up and displaying `you have followed "some_user_here"`, and you instead want to close the window there, then simply replace the alert with `window.close();` instead. –  Mar 29 '15 at 02:42
  • Oh i see. So i just did that and thanks to you I finally got it to close right when I click "follow" and I got the alert box to appear after. But now it doesn't exactly close the popup window, it just minimizes it. Is there a way to get it to completely close? – Scorey Smith Mar 29 '15 at 02:47
  • Get rid of the alert box, and all the code underneath `window.close();`. I highly recommend you go back and do some googling on the situation you're experiencing: You can find almost any answer you're looking for on google. –  Mar 29 '15 at 02:49
  • Well at least I kinda got it to work thanks a lot for your help. I'm gonna play around with it a little. Thanks again :) – Scorey Smith Mar 29 '15 at 02:53

0 Answers0