views:

137

answers:

2

Hi,

I have a thickbox appearing and have created a button which points to a new URL. I want it to work in the following way: 1. Click the button 2. Close the thickbox 3. Set parent window to new url.

I have succeeded in closing the thickbox but cannot get it to open the new url. The code I'm using is as follows: a onclick="javascript:self.parent.tb_remove(); parent.location.href=(this).href(www.google.com.au)"

Cheers,

Shap

+1  A: 

window.location.href = "http://www.google.com.au"

N 1.1
A: 

this in the context of a javascript event handler refers to the actual element itself. So you're basically setting the href attribute of the element itself. You want to set the location of the window as @nvl points out, so that would be

window.parent.location.href = "http://www.google.com.au";
Paul Alexander
Great, but where do I put that code? ie. does it go in the <a> tag?
Shap
You can put it in the href using the javascript: schema like <a href="javascript: ....". However if you're going to be using much javascript you should really be using a framework like JQuery which makes this sorta stuff a bit easier.
Paul Alexander