html:单击链接时执行函数,获取警报,然后重定向到另一个页面 [英] html: execute function when link clicked, get alert and then redirect to another page

查看:95
本文介绍了html:单击链接时执行函数,获取警报,然后重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

组合两个字符串的最佳方式是什么?

字符串1:

 < a href =javascript:myFunc(); onclick =alert('myFunc executed')>点击此处< / a> 


字符串2:

 < a href =http://google.com>点击此处< / a> 

这样:
myFunc()执行;出现
警报;
一旦点击提醒,页面将被重定向到 http://google.com





谢谢。

解决方案试试这个:

< a href =javascript:void(0)onclick =alert('myFunc执行'); myFunc(); window.location ='http://google.com'>点击此处< / a>

<



javascript:void(0)用于查看链接。


What's the best way to combine two strings

String 1:

<a href="javascript:myFunc();" onclick="alert('myFunc executed')">Click here</a>

and String 2:

<a href="http://google.com">click here</a>

so that: myFunc() executed; alert appears; once alert is clicked, the page is being redirected to http://google.com

I'm asking about the most correct way to do that.

Thank you.

解决方案

Try this :

<a href="javascript:void(0)" onclick="alert('myFunc executed');myFunc();window.location='http://google.com'">Click here</a>

explanation :

javascript:void(0) Is for u to see a link.

这篇关于html:单击链接时执行函数,获取警报,然后重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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