Log in

View Full Version : close pop-up window by clicking 'download' button



tk421
02-05-2010, 05:34 AM
I'm posting this question on a couple of similar forums (desperately) so let me apologize if you've read it already...

I've read some of the threads about closing a pop-up as a secondary action but the replies were very cursory (suggested adding an onclick attribute to a link) so I am hoping someone can shed more detailed light on the issue.

I have a java pop-up window for downloading selected mp3s from my database (I know some will say I don't need a pop-up window to link to a simple download but for the design of my site I really want to do it this way).

I need my custom 'download' button to not only trigger the normal browser download dialog (which it does perfectly) but I need the pop-up window to close on the same button click.

The problem is (I think) that the href is embedded in php and I'm not sure where to put the 'onclick' code.

Here is the line of code that tells the 'download' button what to do:

<td align="center" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_FREE_DOWNLOAD, 'id=' . $product_attributes['products_attributes_id']) . '">' . tep_image_button('button_startfreedownload.jpg', IMAGE_BUTTON_CONTINUE) . '</a>'; ?> </td>

I tried every combination of inserting "onClick="javascript:window.close();" in various places in the above code to no avail. I am sure I just do not have a clue where to put it or even if it is the right code to use.

I really hope someone can help. I can post more of the code if necessary.

thanks so much--
yours humbly,
matt

tk421
02-05-2010, 05:39 AM
let me add that someone suggested the following code:

<td align="center" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_FREE_DOWNLOAD, 'id=' . $product_attributes['products_attributes_id']) . '" onClick="javascript:window.close();">' . tep_image_button('button_startfreedownload.jpg', IMAGE_BUTTON_CONTINUE) . '</a>'; ?> </td>

That code actually DID close the pop-pup but the download dialog did not open when I clicked the button.

However - when I used the above code and hovered my mouse over the 'download' button on the pop-up window the proper link did display in the lower part of the pop-up window (with no mention of the 'onclick' stuff).

Any ideas?

-matt