在一定数量的链接点击后重定向页面?

时间:2016-01-10 20:07:07

标签: javascript php html css html5

我是否可以在点击所有链接后重定向页面?这是我到目前为止的代码......

<html class="pixel-ratio-1 watch-active-state">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>This content is locked!</title>

    <link rel="stylesheet" href="../assets/css/framework.css">

    <link rel="stylesheet" href="../assets/css/app.css">
</head>

<body>
    <div class="statusbar-overlay"></div>
    <div class="panel-overlay"></div>
    <div class="views">
        <div class="view view-main" data-page="download">
            <div data-page="about" class="page">

            </div>

            <div data-page="download" class="page no-navbar">
                <center>
                    <p>Download & open <b>2</b> apps below to view these direct messages! </p>
                </center>

                <div class="content-block-title">
                    <center>Free Apps</center>
                </div>
                <div class="list-block media-list">
                    <ul>
                        <div id="apps"></div>
                        <a href="http://tracking.appretail.com/aff_c?offer_id=121&aff_id=133" class="item-link item-content external">
                            <div class="item-media"><img src="../assets/img/cookie-jam.png" width="60"></div>
                            <div class="item-inner">
                                <div class="item-title-row">
                                    <div class="item-title">Cookie Jam</div>
                                    <div class="item-after button" style="color: #007aff;">GET</div>
                                </div>

                                <div class="item-subtitle">
                                    <center>Jam your cookies before they crumble!</center>
                                </div>
                            </div>
                        </a>
                        </li>
                    </ul>


                    <ul>
                        <div id="apps"></div>
                        <a href="http://tracking.appretail.com/aff_c?offer_id=119&aff_id=133" class="item-link item-content external">
                            <div class="item-media"><img src="../assets/img/juice-jam.png" width="60"></div>
                            <div class="item-inner">
                                <div class="item-title-row">
                                    <div class="item-title">Juice Jam</div>
                                    <div class="item-after button" style="color: #007aff;">GET</div>
                                </div>

                                <div class="item-subtitle">
                                    <center>Match and flip fruit to trigger boosters!</center>
                                </div>
                            </div>
                        </a>
                        </li>
                    </ul>
                </div>
                <center>
                    Checking Offer Completion
                    <br>
                    <span style="width:42px; height:42px" class="preloader"></span>
                    <br> After <b>both</b> apps have been opened for 30 seconds this page will be unlocked.
                </center>
            </div>
        </div>
    </div>

    <script type="text/javascript" src="../assets/js/framework.js"></script>
    <script type="text/javascript" src="../assets/js/app.js"></script>
    <script type="text/javascript" src="../assets/js/jquery.js"></script>
</body>
</html>

我在页面上有两个联盟链接。单击两个页面后,我需要将页面重定向到商品完成页面。

有什么想法吗?

2 个答案:

答案 0 :(得分:2)

我想到的方法是这样的

<a href="#" id="link1">Link1</a>
<a href="#" id="link2">Link2</a>

<script>
    var linksClicked = {
        link1 : false,
        link2 : false
    }
    $('a').on('click', function(e){
        e.preventDefault()
        linksClicked[$(this).attr('id')] = true

        if(linksClicked.link1 === true && linksClicked.link2 === true)
           window.location = 'http://example.com'
    })
</script>

答案 1 :(得分:0)

$(".item-link").click(function(){
  $(this).addClass("clicked");
  if($(".item-link:not(.clicked)").length == 0){
    window.location = "redirect link"
  }
});

您可能还想在不同标签上打开优惠,因此请在链接中使用target='_blank'