-2

I have a html button with a javascript to go to another page, but somehow the script doesn't work. Probably because I'm doing it wrong. Please correct me .

    this.onclick = function(event)
{ 
location.href = 'http://www.google.com';
}

I should perhaps clarify that the button is generated by Birt Designer Pro. Its code is almost inaccessible, but this is from the xml:

<extended-item extensionName="HTMLButton" name="NewHTML Button" id="32"> <expression name="text" type="constant">klik</expression> </extended-item>
joe loss
  • 33
  • 6
  • 1
    Add complete code. HTML and Javascript – Tushar Aug 28 '15 at 09:02
  • [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – Andreas Aug 28 '15 at 09:04
  • Might be a problem of `this` use. Make sure `this` is really your button. As @Tushar said, attach the rest of the code so we can help you. – Killian Saint cricq Aug 28 '15 at 09:05
  • Is your button like that `` ? No need of `this` because it's already used on a button – Hearner Aug 28 '15 at 09:05
  • Obviously not @Hearner you can see `this.onclick` in the question source code... Also I agree with Tunshar, we need the full javascript source code for this, maybe display the html element(s) you have related to this. – NewToJS Aug 28 '15 at 09:06
  • uh... The button is generated by Birt Designer Pro. This from the xml file: klik – joe loss Aug 28 '15 at 11:39

1 Answers1

-1

Just use

window.location="http://www.testpage.com";

to redirect from current to "http://www.testpage.com" in your javascript.

SaviNuclear
  • 886
  • 1
  • 7
  • 19
  • Just read this Post http://stackoverflow.com/questions/7077770/window-location-href-and-window-open-methods-in-javascript – SaviNuclear Aug 28 '15 at 09:41
  • This reference You've linked has nothing to do with this case. `open` is not the same as `location.href`. Also Your solution does not solve the problem. – István Pálinkás Aug 28 '15 at 12:15