| 9 |
lars |
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
|
|
3 |
<head>
|
|
|
4 |
<title>Downloadify</title>
|
|
|
5 |
<style type="text/css" media="screen">
|
|
|
6 |
body {background: #fff; width: 500px; margin: 20px auto;}
|
|
|
7 |
label, input, textarea, h1, h2, p { font-family: Arial, sans-serif; font-size: 12pt;}
|
|
|
8 |
input, textarea { border: solid 1px #aaa; padding: 4px; width: 98%;}
|
|
|
9 |
label { font-weight: bold;}
|
|
|
10 |
h1 { font-size: 30pt; font-weight: bold; letter-spacing: -1px;}
|
|
|
11 |
h2 { font-size: 14pt;}
|
|
|
12 |
pre { overflow: auto; padding: 10px; background: #222; color: #ccc;}
|
|
|
13 |
</style>
|
|
|
14 |
<script type="text/javascript" src="js/swfobject.js"></script>
|
|
|
15 |
<script type="text/javascript" src="js/downloadify.min.js"></script>
|
|
|
16 |
</head>
|
|
|
17 |
<body onload="load();">
|
|
|
18 |
<h1>Downloadify Example</h1>
|
|
|
19 |
<p>More info available at the <a href="http://github.com/dcneiner/Downloadify">Github Project Page</a></p>
|
|
|
20 |
<form>
|
|
|
21 |
<p>
|
|
|
22 |
<label for="filename">Filename</label><br />
|
|
|
23 |
<input type="text" name="filename" value="testfile.txt" id="filename" />
|
|
|
24 |
</p>
|
|
|
25 |
<p>
|
|
|
26 |
<label for="data">File Contents</label><br />
|
|
|
27 |
<textarea cols="60" rows="10" name="data" id="data">
|
|
|
28 |
Whatever you put in this text box will be downloaded and saved in the file. If you leave it blank, no file will be downloaded</textarea>
|
|
|
29 |
</p>
|
|
|
30 |
<p id="downloadify">
|
|
|
31 |
You must have Flash 10 installed to download this file.
|
|
|
32 |
</p>
|
|
|
33 |
</form>
|
|
|
34 |
|
|
|
35 |
<script type="text/javascript">
|
|
|
36 |
function load(){
|
|
|
37 |
Downloadify.create('downloadify',{
|
|
|
38 |
filename: function(){
|
|
|
39 |
return document.getElementById('filename').value;
|
|
|
40 |
},
|
|
|
41 |
data: function(){
|
|
|
42 |
return document.getElementById('data').value;
|
|
|
43 |
},
|
|
|
44 |
onComplete: function(){ alert('Your File Has Been Saved!'); },
|
|
|
45 |
onCancel: function(){ alert('You have cancelled the saving of this file.'); },
|
|
|
46 |
onError: function(){ alert('You must put something in the File Contents or there will be nothing to save!'); },
|
|
|
47 |
swf: 'media/downloadify.swf',
|
|
|
48 |
downloadImage: 'images/download.png',
|
|
|
49 |
width: 100,
|
|
|
50 |
height: 30,
|
|
|
51 |
transparent: true,
|
|
|
52 |
append: false
|
|
|
53 |
});
|
|
|
54 |
}
|
|
|
55 |
</script>
|
|
|
56 |
<h2>Downloadify Invoke Script For This Page</h2>
|
|
|
57 |
<pre>
|
|
|
58 |
Downloadify.create('downloadify',{
|
|
|
59 |
filename: function(){
|
|
|
60 |
return document.getElementById('filename').value;
|
|
|
61 |
},
|
|
|
62 |
data: function(){
|
|
|
63 |
return document.getElementById('data').value;
|
|
|
64 |
},
|
|
|
65 |
onComplete: function(){
|
|
|
66 |
alert('Your File Has Been Saved!');
|
|
|
67 |
},
|
|
|
68 |
onCancel: function(){
|
|
|
69 |
alert('You have cancelled the saving of this file.');
|
|
|
70 |
},
|
|
|
71 |
onError: function(){
|
|
|
72 |
alert('You must put something in the File Contents or there will be nothing to save!');
|
|
|
73 |
},
|
|
|
74 |
swf: 'media/downloadify.swf',
|
|
|
75 |
downloadImage: 'images/download.png',
|
|
|
76 |
width: 100,
|
|
|
77 |
height: 30,
|
|
|
78 |
transparent: true,
|
|
|
79 |
append: false
|
|
|
80 |
});
|
|
|
81 |
</pre>
|
|
|
82 |
|
|
|
83 |
</body>
|
|
|
84 |
</html>
|