tags:

views:

33

answers:

2

Hi,

I've got a jquery-ui button. When clicked, I want to move the browser to a url within my domain:

<button onclick='foo'>Go</button>

function foo() {
    window.location('/otherpage');
}

is that the right way to do it, and address it relatively? Is there a better way to do this?

Thanks

+1  A: 

$('#button-id').click(function() { window.location.pathname = '/otherpage'; });

What do you mean by relatively? To the current page or to the current host? There are a few options you are able to use.

ikanobori
+1. This solution requires jQuery, but it doesn't require a javascript onclick attribute in the html code, which is nice.
Rasmus Kaj
Yes, I was assuming a jQuery solution should be the one considering the question asker is using jquery-ui.
ikanobori
+1  A: 

It should be window.location = '/otherpage'; Other than that I think it's fine.

Aidan Brumsickle