0

Seems like this should be obvious but...How can you use a famo.us surface as a link to another webpage?

I've tried:

this.fooSurface.on("click", function(){
        window.location.replace("www.foo.com");
    });

but this doesn't replace the URL, it just puts the new URL on the end of the address currently in the URL bar. window.location.href = "www.foo.com" has the same result.

EDIT: window.location.assign("www.foo.com") and window.location = ("foo") also have the same result. I think this has something to do with this script in the boilerplate index.html:

 <script type="text/javascript">
        require.config({baseUrl: 'src/'});
        require(['main']);
 </script>
Sam Seidenberg
  • 153
  • 1
  • 7

2 Answers2

0

Use window.location.assign("http://www.foo.com"); instead.

I probably wouldn't use the replace() method personally, as replace() switches the current page's place in the document history with that of the one you provide to the method, which I can't say I've ever found beneficial as a user unless there's a blank intermediary login page or something very specific (and temporary).

Or you can even just use window.location = "http://www.foo.com";

https://developer.mozilla.org/en-US/docs/Web/API/Window.location

Kraig Walker
  • 812
  • 13
  • 25
0

I was able to get things working just fine with the boilerplate generator-famous gives you. The script tag has nothing to do with it. That's configuration for RequireJS to load in the famo.us library with AMD.

var logo = new ImageSurface({
    size: [200, 200],
    content: '/content/images/famous_logo.png',
    classes: ['backfaceVisibility']
});

logo.on('click', function() {
    window.location.href ='http://www.google.com';
});

This problem you're having is also not a famo.us problem. It's your Javascript...

Kraig Walker
  • 812
  • 13
  • 25