TinyURL popup opening instead a tab

744 Views Asked by At

I gotta an uncommon problem over here.

I have to call the tinnyURL service to shorten my URL, it is working fine. After that, I have to call another tab, but for some reason, it calls a pop-up.

I'm assuming that the problem is when I call the tinyURL service, but I don't know how to fix it.

Below is the code I've wrote for this.

variables.url = String("http://www.google.com");
sendAndLoad("http://tinyurl.com/api-create.php", variables);


// tinyURL service
private function sendAndLoad( url:String, _vars:URLVariables ):void {

    request = new URLRequest(url);
    request.data = _vars;
    request.method = URLRequestMethod.POST;
    _urlloader = new URLLoader();
    _urlloader.dataFormat = URLLoaderDataFormat.TEXT;


    _urlloader.addEventListener(Event.COMPLETE, handleComplete);
    _urlloader.load(request);

}
// once I get the tinyURL response this function is triggered 
private function handleComplete(event:Event):void {
    var s:String = event.target.data;
    finalURL = "http://twitter.com/home?status=" + MESSAGE + " " + s;
    var url:URLRequest = new URLRequest(finalURL);
    navigateToURL(url); 
}

So I have the same "way-to-do" for the facebook (without the tinyURL) and it works properly, I think it is a problem within the first method (sendAndLoad();)

I've used already alternatives like:

http://skovalyov.blogspot.com/2007/01/how-to-prevent-pop-up-blocking-in.html and http://snipplr.com/view.php?codeview&id=29544

PS:The twitter is working IF I unblock the pop ups on chrome. All I want to do is to open in a new tab.

Let me know if you guys already had some problem like that, it is pretty troublesome!

Thank you.

2

There are 2 best solutions below

0
On

It's me again, I just have figured out the problem.

All I did was to avoid the TinyURL service and call directly the Twitter page updater as below.

var myString:String = "http://twitter.com/home?status=" + MESSAGE + " " + LINK;
var url:URLRequest = new URLRequest(myString);
navigateToURL(url);

Luckily, the Twitter has its own URL shortener, when you concatenate a "http://" to the rest of the url, it does the dirty work.

Thank you all

0
On

There can be many reasons for having your popups blocked, but in this case I bet it's because the popup is not in reaction to a user event such as a click or keyboard input.

In your case that would mean doing the url shortening in the background before even letting the user choose to post to twitter, and when they do that you open that new page in response to their mouse event.