I'm not sure if this is the right place as I'm referencing JS. I'm new this but I'm trying to learn.

Right now I'm using a script on a page, where the link will resize the window to a certain size.

function cont()
window.resizeTo(900, 750);
// -->

and the link

<a href="javascript:cont();">link</a>

Leads to redirect.php which contains:

 header( 'Location: http://www.yoursite.com/' ) ;

This works great except on the first page, when the user hovers over the link it says something about JS in the status bar.

Is there a way to achieve the same effect (resize AND redirect) with the status bar saying http://mysite.com/redirect.php?

8 Years
Discussion Span
Last Post by almostbob

You should put you're javascript in the onclick="" attribute, and add the "redirect.php" to the href attribute, this way, the status bar will say .../redurect.php and your link will work even if javascript is disabled by the user(window won't be resized thou).
I'm not sure how window.location works; you might need to add a "return false" in your onclick attribute.
So your link should look like this:

<a href="redirect.php" onclick="cont();return false;">link</a>

Dude that worked great! Could you explain why "return false" was needed? I looked it up and I was led to believe that would negate the a href and not link out?

I did some other digging and found out about onMouseOver="window.status

I may use this instead as the whole point of my redirect.php was so it looked like the link was to a page on my site, and not a page out. Any negatives on using onMouseOver="window.status besides the chance JS is disabled?


return false purpose is to negate the href if javascript is enabled, the onclick attrribute remains, the script will function, the window will resize and then redirect

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.