javascript - WhatsApp 按钮中的 Onclick 功能
问题描述
我在将输入发送到数据库的订单按钮中有 onclick 功能,在修改按钮后(将其连接到 WhatsApp 而不是数据库)onclick
功能已停止工作......我需要该onclick
功能才能工作。
<form className="orderForm">
<div className="form-group">
<div className="whatsapp" style="margin-top: 20px;">
<button
className="btn-primary"
onClick="reportConversion(event.target)"
type="submit"
style="height:70px;width: 100%;"
>
<img
src="wat.png"
style="width: 36px;height: 36px; position: absolute; margin-left: -40px;margin-top: -10px;"
/>
<a href="https://wa.me/......" style="color: white;font-weight: 600; font-size: 18px;">
...text...
</a>
</button>
</div>
</div>
</form>
解决方案
使用 a 会是一个很好的解决方案Promse
,但是reportConversion
返回未知,也不确定我们可以修改它吗?
无论如何,由于我们具有链接优先级,因此该解决方案可能适合。
注意:请记住将<button>
类型从更改submit
为button
并从内部删除链接。
function reportConversionWrapper(target) {
reportConversion(target);
setTimeout( function() {
window.location.href = 'https://wa.me/......';
}, 1000 );
}
// following is just a filler - don't mind it
function reportConversion(a) {
return;
}
<form className="orderForm">
<div className="form-group">
<div className="whatsapp" style="margin-top: 20px;">
<button
className="btn-primary"
onclick="reportConversionWrapper(event.target)"
type="button"
style="height:70px;width: 100%;"
>
<img
src="wat.png"
style="width: 36px;height: 36px; position: absolute; margin-left: -40px;margin-top: -10px;"
/>...text...
</button>
</div>
</div>
</form>
推荐阅读
- mongodb - 合并相同的结果猫鼬
- python - 熊猫,对于column1的每个唯一值,我想计算column2的每个唯一值出现的次数
- javascript - 画布上的多个数学公式
- elasticsearch - ElasticSearch 中的正则表达式
- sql - 我有 4 列带有 Sum 和 Count 函数。我想将 4 列转换为 4 行
- github - 在哪里可以找到 github 上代码的默认突出显示模式?
- animation - 半旋转导航上的颤振 RotationTransition
- amazon-web-services - 无法在亚马逊 aws ec2 实例中配置 https。Godddy 中托管的域
- angular - 即使在输入字段以反应形式填写后,也会显示 mat-errors
- javascript - 在 XBox 上单击输入字段时以编程方式调出键盘 - UWP App (JS)