I'm trying to set up a simple inline thickbox window for agreeing to the terms of use for a download file. I found styling the box to hold the TOS content statement rather easy, but don't know how to set up a second button that closes the thickbox AND points the user at a zip file to begin download.
The coding snippit for the "Cancel" button that they click when they don't agree is below. I want to add a second button that begins the download process, and also closes the thickbox popup.
>
Since the downloading file is a zip file, I don't think that I have to get very fancy with the coding, because the browser should automatically show the OS Save/Open menu when you direct them to that link? Any ideas on how I can do this? Thanks.
Fagan
In the head add this
In the head add this
<script type="text/javascipt"> function startDownload(file) { var url='http://server/folder/'+file; window.open(url,'Download'); } </script>
And then in your thickbox add
<p style="text-align:center"><input type="submit" id="Download" value=" Download " onclick="tb_remove(); startDownload(fileName.zip);" /></p>
This isn't tested and I'm not a javascript genius, but I think this should work.
Okay...I know NOTHING about
Okay...I know NOTHING about javascript. Sorry. I've tried using your script with a file in mind, and it did not work. What would the syntax in the javascript in the header, and in the tag be for a file named:
http://www.location.com/file.zip
look like? The last option that I tried looked like:
<script type="text/javascipt"> function startDownload(file) { var url='http://www.location.com/file.zip'; window.open(url,'Download'); } </script>
and the in-line code for the button looked like:
<p style="text-align:center"><input type="submit" id="Close" value=" I Agree " onclick="tb_remove(); startDownload(file.zip);" />
I did something wrong here, but I don't know what. Thanks again.
Yes, you changed the
Yes, you changed the structure of the code I provided you, therefore it doesn't work.
<script type="text/javascipt"> function startDownload(file) { var url='http://www.location.com/'+file; window.open(url,'Download'); } </script>
See if that works, if not. please provide a link, and I will be able to see what is going on.
Sorry. I last posted one of
Sorry. I last posted one of the syntax change iterations that I was trying after it did not work the first time. The result is the same.
I also tried putting an old-fashioned anchor tag around the entire button, and that did not work either. It seems that the original JQuery function "tb_romove" does not allow for another javascript function or even anchor tag to work with the same "on-click".
Any other ideas? Thanks.
I found a solution that
I found a solution that works for now. There is something about the content being part of a thick-box inline modal window that precludes using javascript functions that are not already embedded entirely within the JQuery/Thickbox js files.
Since I'm a javascript beginner, and want to cut down on the amount of coding that I need to do when I need to post new files only twice per year, I kept it super simple.
I took an idea from another forum about changing the type from "submit" to "button", and used onlclick="window_open()" to just open the new file. It works in IE6-8, and the last couple of versions of Firefox/Safari/Opera (we have clients with older GIS/database software that require older browsers and older versions of java to function).
The first button above uses a simple window.open() command attached to a button (not submit), without linking to another function located anywhere on the site (on the web page, JQuery, or other js scripts).
<input type="submit" id="Close" value=" Don't Agree " onclick="tb_remove(); " />
The second button uses the native Thickbox/JQuery tb_remove() function to close the window if they dissagree. The native "close window" command at the top of thickbox modal window allows them to close the modal window after they download the file.
Since I'm trying to get the user to download a zip file, the OS-based "Save/Open" automatically window pops up whenever you link directly to the zip file.
I know that this is sloppy, but it seems to work. Any reasons why I should not use it? I would prefer to do a straight-up asp page hooked to a database, but was over-ruled by my boss (pop-up blocking issues, they WANT a modal content window).
Thanks.
