两个URL在函数中使用“window.location.href”; [英] Two URL's in function using "window.location.href"

查看:124
本文介绍了两个URL在函数中使用“window.location.href”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Marketo Embed,允许我在使用它时添加它。

I'm using a Marketo Embed for which allows me to add to it when I use it.

我的目标是使用window.location.href函数打开第一个URL(.zip文件),然后打开一个新的URL(一个页面) 。

My goal is to use the "window.location.href" function to open the first URL (a .zip file) and then open a new URL (a page).

它只使用其中一个URL。如果它们是唯一的函数,那么任何一个都将正常工作。否则它只会触发后者。我已经对它进行了测试,但这一切似乎都是正确的,但它认为我错过了使用window.location.href两次的规则。

It's only using one of the URLS. Either one will work properly if they are the only one if the function. Otherwise it only fires the latter one. I've tested it and it all appears to be right, but it think I'm missing something about the rules with using window.location.href twice.

这是我的代码:

    <script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
    <form id="mktoForm_1198"></form>
    <script>MktoForms2.loadForm("//marketo.com", "000-000-000", 0000, function(form) {
form.onSuccess(function(values, followUpUrl) { 
       window.location.href = "************.zip";
       window.location.href = ".../page.html";
            return false;
    });});
    </script>


推荐答案

试试

<script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1198"></form>
<script>
    MktoForms2.loadForm("//marketo.com", "000-000-000", 0000, function(form) {
        form.onSuccess(function(values, followUpUrl) { 
            var pid = window.setInterval(function() {
                window.location.href = ".../page.html";
                typeof pid !== 'undefined' && window.clearInterval(pid);
            }, 1000);
            window.location.href = "************.zip";
            return false
        ;});
    });
</script>

这篇关于两个URL在函数中使用“window.location.href”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆