Getting a button to complete two actions

Associate
Joined
16 Mar 2004
Posts
1,920
Location
Oxford
I'm currently playing round with a bit of JavaScript, and I am trying to get one button to complete two actions, so it closes the internet explorer window and opens a file, here is what I have so far, but no matter what I do it won’t work:

Code:
<div id="fs"> 
  <FORM METHOD="LINK" onClick="javascript:window.close();javascript:window.open(SPACE.xls)">
    <INPUT TYPE="submit" VALUE="Freespace/Close">
  </FORM>
</div>

So what am I doing wrong and how can I correct it, all it does is closes the current window.
 
Last edited:
Swap the calls around - open first, then close. You also need some quotes around that filename (which you'll have to 'escape' as you're already in a quoted string).

Might work.
 
You'll also be wanting it 'the other way round'

You want the onClick event on the button, not the form.

Code:
<input type="button" value="click me!" onclick="window.open('S  PACE.xls');window.close();" />
also don't forget that the link will be relative to the current url of that page.
 
Back
Top Bottom