1

In crossrider, I've a function in the background-codes as

function buttonClick() {
  alert(2);
  // simulates similar behavior as an HTTP redirect
  var url = "http://12bubbles.com";    
  window.location.replace(url);
}

After installing the extension, when buttonClicked() is called, the alert() did pop up but the redirect doesn't work. Is something wrong with my codes??

Oded
  • 489,969
  • 99
  • 883
  • 1,009
ptamzz
  • 9,235
  • 31
  • 91
  • 147
  • Can you post your solution as an answer and accept it in a few days please. That would really help other users. Thanks! – PeeHaa Jul 19 '11 at 21:23

3 Answers3

7

Finally figured out. If anyone is facing the same problem, I simple had to use their own API

function buttonClick() {
      alert(2);
      // simulates similar behavior as an HTTP redirect
      var url = "http://12bubbles.com";    
      appAPI.openURL(url, "current");
    }
ptamzz
  • 9,235
  • 31
  • 91
  • 147
1

Try window.location.href = url;

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
1
window.location.href = url; 

is the proper syntax

Greg Guida
  • 7,302
  • 4
  • 30
  • 40
  • Still doesn't work. Maybe it's something 'Crossrider' specific then. – ptamzz Jul 19 '11 at 17:21
  • I'm not familiar with cross-rider but I'm surprised that this wouldn't work. Maybe try just `window.location = url`? – Greg Guida Jul 19 '11 at 17:27
  • I tried that too. Both works when I tried in localhost but I can't get it working with Crossrider. Anyway, thanks for helping me out!! – ptamzz Jul 19 '11 at 17:42