简体   繁体   English

在没有动画a-tag的情况下,但在动画播放完毕后,建立到其他页面的超链接

[英]Make an hyperlink to an other page without the HTML a-tag, but after an animation finished playing

I would like to make a web banner and I want it to have a hyperlink to an other page. 我想制作一个网页横幅,并希望它具有指向其他页面的超链接。

Sounds like an easy task? 听起来很容易? Yes, but I can't use the HTML tag because I don't want to go to an other page started by a click event. 是的,但是我不能使用HTML标记,因为我不想转到由click事件启动的其他页面。

I want to link to an other page after an animation finished playing. 动画播放完毕后,我想链接到另一个页面。

I'm hoping for a JS solution (if it's possible). 我希望有一个JS解决方案(如果可能)。

so: 所以:

First: I want to drag and drop an html-element, 首先:我想拖放一个html元素,

Second: I want to play an CSS/JS animation, 第二:我想播放CSS / JS动画,

Third: I want to hyperlink to an other page, (this is the part were in need help). 第三:我想超链接到另一个页面,(这是需要帮助的部分)。

I don't have any code an don't ask to write it for me, I just want to know how to make a hyperlink without clicking something. 我没有任何代码,也不需要为我编写代码,我只是想知道如何制作超链接而无需单击任何东西。

I have found an similar question Here , but it doesn't cover what I'm looking for. 在这里找到了类似的问题,但没有涵盖我所寻找的内容。 I want to link after the user interacted. 用户互动后,我想链接。

You set the window.location.href="http://www.stackoverflow.com"; 您设置window.location.href="http://www.stackoverflow.com";

Here is an example of how you would do it at the end of an animation using jQuery. 这是一个示例,说明如何在使用jQuery的动画结束时执行此操作。

JavaScript JavaScript的

$("#startAnimation").on('click',function(){
  $("#bunny").slideDown(1000,function(){
    window.location.href="http://www.stackoverflow.com";
  });

});

CSS CSS

#bunny {  
  display:none;
}

HTML HTML

  <div id="bunny"><img src="http://i.guim.co.uk/static/w-620/h--/q-95/sys-images/Guardian/Pix/pictures/2010/8/5/1281041145130/Farms-wildlife-schemes-bo-006.jpg"/></div>
<div>
    <button id="startAnimation" type="button">Start animation</button>
</div>

See the JSBin 见JSBin

After the animation has finished playing, you can run a script that would redirect the user to another page: 动画播放完毕后,您可以运行将用户重定向到另一个页面的脚本:

window.location.href = 'your_page.html'; window.location.href ='your_page.html';

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

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