简体   繁体   English

使下载按钮重定向到页面?

[英]Make a download button redirect to a page?

I have a script resembling a page protector / redirecting links. 我有一个类似于页面保护程序/重定向链接的脚本。 It is in the directory: 它在目录中:

/ROOT/redirect / ROOT /重定向

When we add a link in front of it, as in the example below: 当我们在其前面添加链接时,如下例所示:

http://mysite.net.ex/redirect/?url=linkthedownloadpage http://mysite.net.ex/redirect/?url = link下载页面

It redirects after 15 seconds for the link. 链接在15秒后重定向。

But I wanted to know how to show a download button at the bottom of this page to link. 但我想知道如何在此页面底部显示下载按钮以进行链接。 Parecido like this: Parecido像这样:

http://3.bp.blogspot.com/_ZguH4ax2gDs/TNm9hf3URiI/AAAAAAAAAFQ/rYgn5MOzfzo/s1600/folder-download.png http://3.bp.blogspot.com/_ZguH4ax2gDs/TNm9hf3URiI/AAAAAAAAAFQ/rYgn5MOzfzo/s1600/folder-download.png

How do I do this? 我该怎么做呢?

Here is the script of my page, if someone can give me better, thanks: 这是我页面的脚本,如果有人可以给我更好的帮助,谢谢:

http://jsfiddle.net/JZ5pu/ http://jsfiddle.net/JZ5pu/

Your code is a total mess. 您的代码是一团糟。 Try tidying it up first. 尝试先整理一下。

Afterwards, try changing your function AtualizaTempo() to this: 然后,尝试将函数AtualizaTempo()更改为此:

function AtualizaTempo() {
  tempo = document.getElementById("div_tempo").innerHTML
  tempo = parseInt(tempo)
  tempo--
  if (tempo>0) {
    document.getElementById("div_tempo").innerHTML = tempo
    setTimeout('AtualizaTempo()', 1000)
  } else {
    div=document.getElementById('download_link');
    a=document.createElement('a');
    div.appendChild(a);
    a.href='[here goes your link]'

    img=document.createElement('img');
    a.appendChild(img);
    img.src='[here goes URL to the image]';
    img.border='0';
  }
}

Then, in the bottom of your page where you want the image to appear, just insert: 然后,在您要显示图像的页面底部,只需插入:

<div id="download_link"></div>

You could also make the link harder to read for an average user, if you used some sort of encoding. 如果您使用某种编码,也可以使普通用户更难以阅读该链接。 The simpliest one that comes in mind is just escaping it URL style. 想到的最简单的方法就是转义URL样式。 (See this link for example). (例如,请参阅此链接 )。 The line with href in AtualizaTempo() then becomes: AtualizaTempo()中带有href的行将变为:

a.href=unescape('[here goes your URL escaped string]');

Hope this helps. 希望这可以帮助。

By the way did you use Google Translator? 顺便问一下,您是否使用过Google Translator?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM