[B]simply, i made a images explorer for my site,
i want to allow users to download any image by clicking on the download button.
[SIZE=”3″]anyone can help me ?
HERE IS THE CODE:
first: HTML codes
[code=html]<input id=”btnPrev” disabled onclick=”prev()” type=”button” value=” prev ” name=”btnPrev”>
<input id=”btnDl” disabled onclick=”” type=”button” value=”DownLoad” name=”btnDl”>
<input id=”btnNext” disabled onclick=”next()” type=”button” value=” next ” name=”btnNext”>
Second: JS functions
[CODE]var no_of_imgs = 24;
var imgs = new Array(no_of_imgs);
var imgWidth = 265;
var imgHeight = 150;
var currentImg=0;
for(i=0;i<=no_of_imgs;i++){
imgs[i] = new Image()
imgs[i].src = “wallpapers/”+i+”.jpg”
}
function doImg(){imgsDiv.innerHTML=”<img height=” +imgHeight+ ” width=” + imgWidth + ” src=” + imgs[currentImg].src + “>”}
function next(){
btnPrev.disabled=false
if (currentImg == no_of_imgs){ btnNext.disabled=true }
else { currentImg++ ; doImg() }
}
function prev(){
btnNext.disabled=false
if (currentImg==0){ btnPrev.disabled=true }
else { currentImg– ; doImg() }
UpDate()
}
function Pageloaded(){
doImg()
btnNext.disabled =false
}
the HTML page in the attachments as a text file ?
Please i want help to make a function for my download button ?
and i hope from our expert coders if there is any comments on my (beginner) coding, so i edit it and practice my self.
THANKS FOR ALL
[upl-file uuid=800e7875-d48a-4f84-9bcd-826d73eecbef size=3kB]wallpapers.txt
<a href="anImage.gif">download anImage.gif</a>
<a href="anImage.gif">download anImage.gif</a>[/QUOTE]
Any function using document.write after page load will create a new document![/QUOTE]
<a href="anImage.zip">download anImage.gif</a>
[code=php]
<?php
header("Content-Type:image/png");
header("Content-Disposition:attachment;filename=ultimater.png");
//Use inline instead of attachment if you don't want it to force a download.
echo file_get_contents("https://webdeveloper.com/forum/image.php?u=30185&dateline=1128637189");
?>
[/code]
<i>
</i><iframe src="about:blank" name="hiddenframe" style="border:0; width:0; height:0; position:absolute;"></iframe>
<i>
</i><form target="hiddenframe" action="downloadimage.php?file=ulti.png" method="get">
<input type="submit" value="Download">
</form>
<i>
</i><a target="hiddenframe" href="downloadimage.php?file=ulti.png">Download</a>
<i>
</i><IfModule mod_headers.c>
<Directory /var/www/download>
Order allow,deny
Allow from all
<FilesMatch ".(gif|jpe?g|png)$">
Header append Content-Disposition "attachment;"
</FilesMatch>
</Directory>
</IfModule>
<i>
</i><Files ~ ".(gif|jpe?g|png)$">
Header append Content-Disposition "attachment;"
</FilesMatch>
<i>
</i><script type="text/javascript">
function saveMe(myFile){
try{
myTempWindow = window.open(myFile,"tmpwindow");
myTempWindow.document.execCommand("SaveAs",null,myFile);
myTempWindow.close();
return false;
}catch(E){
return true
}
}
</script>
<a href="[color=blue]ulti.png[/color]" target="_new" onclick="return saveMe(this.getAttribute('href'))">Download Me</a>
<i>
</i><iframe src="data:application/x-octet-stream;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw
AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz
ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp
a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl
ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis
F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH
hhx4dbgYKAAA7">
[code=php]execCommand("SaveAs",null,myFile);[/code]
[code=php]catch(E){
return true
}[/code]
[code=php]return false;[/code]
<i>
</i><a href="http://www.google.com" target="_new" onclick="return false">Disabled Link</a>
<br>
<a href="http://www.google.com" target="_new" onclick="return true">Enabled Link</a>
<i>
</i><iframe src="data:application/x-octet-stream;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw
AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz
ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp
a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl
ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis
F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH
hhx4dbgYKAAA7">
<i>
</i>data:text/html;utf-8,<strong>This is HTML</string>
<i>
</i>data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7
E is an error object that is created and exists only within the catch block however it is required by JavaScript even though I am not using it[/QUOTE]
JavaScript will not even attempt to run the contents of the containing SCRIPT element at all.[/QUOTE]
[code=php]data:text/html;utf-8,<strong>This is HTML</string>[/code]
[CODE]data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7[/CODE]
[/QUOTE]
you mean typing it between the prackets (E) -or- you mean declare it in the backgroud only by javascript,
[/quote]
<i>
</i><script type="text/javascript">
var E="global value";
alert("The value of the variable "E" is:n"+E)
try{
someFunctionThatDoesntExist();
}catch(E){
alert("The value of the variable "E" is:n"+E)
}
alert("The value of the variable "E" is:n"+E)
</script>
and i want to ask if i can use the E variable as in VisualBasic.NET by appearing the error to the users for example
alert(E.value) or whatever.
[/quote]
<i>
</i><script type="text/javascript">
try{
someFunctionThatDoesntExist();
}catch(E){
var t=new Array();
for(var j in E)t.push("E."+j+":n"+E[j]);
alert(propertiesOfE=t.join("nnn"))
}
</script>
<i>
</i><script type="text/javascript">
try {
someFunctionThatDoesntExist();
} catch (e) {
alert(
"TypeError: "+(e instanceof TypeError)+"n"+ //IE
"RangeError: "+(e instanceof RangeError)+"n"+
"EvalError: "+(e instanceof EvalError)+"n"+
"ReferenceError: "+(e instanceof ReferenceError)+"n"+ //Firefox
"SyntaxError: "+(e instanceof SyntaxError)+"n"+
"URIError: "+(e instanceof URIError)+"n"+
"Error: "+(e instanceof Error)+"n" // IE,Firefox
);
}
</script>
the second thing is i want to know why you typed return true not return false in the catch block..
[/quote]
<i>
</i><a href="http://www.google.com" target="_new" onclick="return false">Disabled Link</a>
<br>
<a href="http://www.google.com" target="_new" onclick="return true">Enabled Link</a>
you mean that javascript will not run all the contains bec. <script> and </script> or what ??
[/quote]
i know that i asks many questions but i am relly sorry, i have other questions but i will not ask it bec. it will take a ""hard work"" from you.[/QUOTE]
0.1.9 — BETA 5.16