如何让我的所有网页链接开放延迟?

时间:2013-01-14 23:52:23

标签: jquery html5

我想知道是否有人有延迟时间的经验?我试图让我的所有全球链接以延迟时间打开。只是为了给它一个艺术效果,让它更顺畅地交换页面。但由于某种原因我无法让它工作。我很感激我能得到任何帮助。

HTML:

    <!DOCTYPE html>
<html lang="en-US">
    <head>
    <meta charset="utf8" />
        <link rel="stylesheet" type="text/css" media="all" href="css/mainstyle.css"/>
        <meta name="viewport" content="initial-scale=1" />
        <title> Redneck Rampage </title>
    </head>
    <body class="filter">
    <div id="background"> 
        <div id="wrapper">
            <div class="navigation">
                <ul id="mainmenu">
                    <li class="active"><a href="index.html">Home</a></li>   
            <li><a href="band.html">Band</a></li>  
            <li><a href="news.html">News</a></li>
                    <li><a href="shows.html">Shows</a></li>
                    <li><a href="music.html">Music</a></li>
                    <li><a href="gallery.html">Gallery</a></li>
                    <li><a href="media.html">Media</a></li>
                    <li><a href="store.html">Store</a></li>

                </ul>
            </div>

                <div class="footer homepage">
                    <p class="rednecks">Website and Contents &copy; Redneck Rampage 2013. </p>
                    <p class="signature">Designed by Martin Metsalu </p>

                        <ul id="footermenu">
                            <li><a href="terms.html">Terms of use</a></li>
                            <li><a href="privacy.html">Privacy Policy</a></li>
                            <li><a href="contact.html">Contact</a></li>
                       </ul>
                    <div class="socialplugins">
                        <div class="test"><a href="#"><img src="IMG/soundcloud.png" alt="plugin#1" ></a></div>        
                        <div class="test"><a href="#"><img src="IMG/youtube.png" alt="plugin#2"></a></div>
                        <div class="test"><a href="#"><img src="IMG/myspace.png" alt="plugin#3"></a></div>
                        <div class="test"><a href="#"><img src="IMG/facebook.png" alt="plugin#4"></a></div>

                    </div>

                </div>
         </div>
    </div>
</body>
</html>

JQUERY:

        $('a').click(function(e) {
$('a[href*="/steve"]').each(function(index) {
    setTimeout(
         function(href){window.open(href)},
         (index+1)*5000, $(this).attr('href')
    );
});

2 个答案:

答案 0 :(得分:1)

$( 'a[href*="/steve"]' ).each( function () {
    $( this ).on( 'click', function ( event ) {
        event.preventDefault();
        ( function ( h ) {
            setTimeout( function () {
                window.location = h;
            }, 5000 );
        })( this.href );
    });
});

试一试。

答案 1 :(得分:0)

我认为您只需要在点击功能的顶部执行e.preventDefault();

相关问题