Same button to download and open a different URL
Moderator: General Moderators
-
Maluendaster
- Forum Contributor
- Posts: 124
- Joined: Fri Feb 25, 2005 1:14 pm
Same button to download and open a different URL
Can someone share a code to open a new window, but at the same time it has to redirect (not the open window) to a file.... I had it but i formated my PC.. And i cant remember how it's done..
thank you.
thank you.
-
Maluendaster
- Forum Contributor
- Posts: 124
- Joined: Fri Feb 25, 2005 1:14 pm
-
Maluendaster
- Forum Contributor
- Posts: 124
- Joined: Fri Feb 25, 2005 1:14 pm
Re: Same button to download and open a different URL
ah! i forgot to ask how to make a "countdown" , for example,Maluendaster wrote:Can someone share a code to open a new window, but at the same time it has to redirect (not the open window) to a file.... I had it but i formated my PC.. And i cant remember how it's done..
thank you.
Wait 15 seconds to download the file
and after 15 seconds, the download link will appear...
I want to do this without a DB
#1Before You Ask
Before asking a technical question by e-mail, or in a newsgroup, or on a website chat board, do the following:
1. Try to find an answer by searching the archives of the forum you plan to post to.
2. Try to find an answer by searching the Web.
3. Try to find an answer by reading the manual.
4. Try to find an answer by reading a FAQ.
5. Try to find an answer by inspection or experimentation.
6. Try to find an answer by asking a skilled friend.
7. If you're a programmer, try to find an answer by reading the source code.
Code: Select all
<script type="text/javascript">
function open_window(){
// Whatever popup window code you want to use...
window.open("http://www.devnetwork.net","Devnetwork");
// Link to File to Download or Page to go to
document.location = 'http://www.google.com';
}
</script>
<a href="javascript:open_window();">Test</a>Code: Select all
<html>
<head>
<script type="text/javascript">
function show_download(){
document.getElementById('download_link').innerHTML = '<a href="http://www.google.com">www.google.com</a>';
}
</script>
</head>
<body onload="setTimeout('show_download();',15000);">
<div id="download_link">
</div>
</body>
</html>-
Maluendaster
- Forum Contributor
- Posts: 124
- Joined: Fri Feb 25, 2005 1:14 pm
I'm happy to help out here, but we're (the community here) is not all about doing work for free. We help everyone out.Maluendaster wrote:thank man!! both scripts worked...but I have the last qustion
Is there a way to put a countdown in numbers... like 15...14...13 and the show the download link.
Have you tried to do it this yourself? If so post the code, and explain problems you have had.
-
Maluendaster
- Forum Contributor
- Posts: 124
- Joined: Fri Feb 25, 2005 1:14 pm
i have this from another site,it should work, but it's not
Code: Select all
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function download () {
document.getElementById('div1').style.display= 'none';
document.getElementById('div2').style.display= '';
return true;
}
function load () {
document.getElementById("div2").style.display = "none";
document.getElementById('div1').style.display= '';
return true;
}
//-->
</script>
<div id="div1">
<script language="Javascript">
var ts = 30; tuw1();
var loc = '';
function tuw1(){
if(ts>0){document.getElementById("div1").innerHTML = "Please wait " + ts + " seconds.";
ts = ts - 1;
setTimeout("tuw1()", 1000)} else {document.getElementById("div1").innerHTML = '<a href="#" onClick="return download();">Download file</a>';}}
</script></div>Its because you need to call load(); when the pages loads.
But he is my countdown example i made..
Code: Select all
<body onload="load();">
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
// Time in Ms
var time = 10000;
// Time to subtract
var subtract = 1000;
function show_download(){
document.getElementById('download_link').innerHTML = '<a href="http://www.google.com">www.google.com</a>';
}
function count(){
if(time>=0){
setTimeout('subt(subtract);',subtract);
document.getElementById('download_link').innerHTML = time/1000 + ' seconds remaining';
}else{
show_download();
}
}
function subt(remove){
time = time-remove;
count();
}
</script>
</head>
<body onload="count();">
<div id="download_link">
</div>
</body>
</html>