javascript - 单击 html 中的下载链接后重定向

标签 javascript html

我的页面中有一个下载 PDF 文件的链接,但是在他们单击任一下载链接后,我想将他们带到另一个页面。

该页面为他们提供了选择下载文件的两种选择之一,但我只想允许他们做出一个选择,然后退出到另一个页面。

我的代码如下:

<div class="columns medium-6">
    <h3 class="text-center">7 Tips for Creating a <br />Happy Workplace</h3> <img src="https://www.maylake.com.au/_assets/images/mini-guide/bookcover-7-tips-workplace.png" height="250px" alt="7 Tips for Creating a Happy Workplace eBook">
    <p style="font-size: 18px;" class="text-center">Discover how you can make your workplace a healthier environment by simply making being a happy place to work for everyone</p>
    <div class="choose">
        <input type="radio" name="choice-books" id="choice-7-tips">
        <label>I would like to receive a copy of the eBook</label>
        <div class="reveal-if-active">
            <p class="text-center"><a href="/LiteratureRetrieve.aspx?ID=192014" class="button radius text-center">DOWNLOAD Now</a> </p>
        </div>
    </div>
</div>
<div class="columns medium-6">
    <h3 class="text-center">Your Short Guide to Leasing a Commercial Office Space</h3> <img src="https://www.maylake.com.au/_assets/images/mini-guide/bookcover-leasing-commercial-office.png" alt="Guide to Leasing Commercial Office" height="250">
    <p style="font-size: 18px;" class="text-center">Understand what you should be considering before leasing any commercial office space. Being forewarned and prepared could save you lots
        of money and grief</p>
    <div class="choose">
        <input type="radio" name="choice-books" id="choice-leasing">
        <label for="choice-leasing">I would like to receive a copy of the eBook</label>
        <div class="reveal-if-active">
            <p class="text-center"><a href="/LiteratureRetrieve.aspx?ID=192012" class="button radius text-center">DOWNLOAD Now</a> </p>
        </div>
    </div>
</div>

最佳答案

我会将您的 a 元素更改为如下所示:

<a target="_blank" href="/LiteratureRetrieve.aspx?ID=192014" class="button radius text-center" onclick="window.location='http://google.com';">DOWNLOAD Now</a> 

这将在他们下载 pdf 的同时访问 google.com。

关于javascript - 单击 html 中的下载链接后重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53308688/

相关文章:

javascript - 用于渐变的 CSS3 Javascript 库?

javascript - HTML 逐列添加数据而不是逐行添加数据

javascript - 如何创建 4 列的布局,其中一列具有动态宽度,其他 3 列是偶数?

html - 两个其他 div 之间的自动高度

html - html 中的中心 Logo

javascript - 如何设置youtube api的播放质量

javascript - 从手机发送文件到 Node js 服务器

javascript - 从右到左的 CSS 过渡宽度

javascript - 从 firebase 实时数据库中检索数据并自动填充到文本框中

javascript - 翻页响应式