Don, the following code should work in all major browsers - certainly I've 
tested in Firefox 3, IE7, Chrome, and Opera 9.


Here's the HTML:

<button type="button" class="download" 
data-file="http://xyz.com/somefile.zip";>Download the File</button>


Note how I've used a class there - instead of inline styles - here is the 
styling:

<style type="text/css">
        button.download
        {
                background-color: lightgreen;
                width: 150px;
        }
</style>


Finally, here is the scripting to use:

<script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js";></script>
<script type="text/javascript">
        $j = jQuery.noConflict();

        $j(document).ready
        ( function()
                {
                        $j('.download').click( downloadFile );
                }
        );

        function downloadFile()
        {
                location.href = $j(this).attr('data-file');
        }
</script>


This is all a lot of code, but it is a more reliable/flexible way of doing it, 
especially for when (not if) you need to extend things.

Feel free to ask if any of this is unclear. :) 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321188
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to