在博客作者中,我试图在打开whatsapp-web共享按钮的新标签之前出现一个确认框
<html>
<a class='whatsapp' data-confirm="Some Question?"
expr:href='"https://web.whatsapp.com/send?text=" + data:post.title + " >> " + data:post.url' rel='nofollow' target='_blank'>Share Web Whatsapp</a>
</html>
<script type='text/javascript'>
var openTab = document.querySelectorAll('.whatsapp');
for (var i = 0; i < openTab.length; i++) {
openTab[i].addEventListener('click', function(event) {
event.preventDefault();
var choice = confirm(this.getAttribute('data-confirm'));
if (choice) {
window.location.href = this.getAttribute('expr:href');
}
});
}
</script>
问题是,当我单击“是”时,链接将无法加载
答案 0 :(得分:0)
我建议您使用SWAL(甜蜜提醒)
https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js
引导程序和JQUERY
,然后在文件中的javascript中添加一些代码行,但先清除所有代码并测试我的代码。
$("#yourwhatsappbutton").click(function(){
Swal.fire({
type: 'warning',
title: 'Are you sure to share it on whatsapp?',
confirmButtonText: 'Cancel',
showConfirmButton: false,
showCancelButton: true,
customClass:{
cancelButton: 'btn-danger',
},
html:
'<br><button id="rec" class="btn btn-lg btn-success text-center">' +
'share it on whatsapp' +
'</button><br/>',
onBeforeOpen: () => {
rec.addEventListener('click', () => {
//Running this code when user select share it
window.location.href = "https://web.whatsapp.com/send?text=" + data:post.title + " >> " + data:post.url";
})
},
onClose: () => {
}
})
});
$(“#yourwhatsappbutton”)。click(function(){
您的共享WhatsApp按钮称为
时触发功能
标题:“确定要在WhatsApp上共享吗?”,
如果需要,请更改标题文字。
confirmButtonText:“取消”,
showConfirmButton:否,
showCancelButton:是,
customClass:{
cancelButton:“ btn-danger”
照原样复制。
html:
'
'+
“在WhatsApp上共享” +
'
',
创建共享Whatsapp按钮并为其赋予ID,然后再访问它。
sharebutton.addEventListener('click',()=> {
//当用户选择共享时运行此代码
window.location.href =“ https://web.whatsapp.com/send?text=" + data:post.title +” >>“ + data:post.url”;
})
运行并调用whatsapp
答案 1 :(得分:0)
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
app = Flask(__name__)
@app.route("/sms", methods=['GET', 'POST'])
#define method to split the input
def sms_ahoy_reply():
"""Respond to incoming messages with a friendly SMS."""
# Start our response
resp = MessagingResponse()
country = request.values.get('FromCountry')
toDoList = []
splitext = request.args.get('body','').split()
msgSplit = list(splitext)
if msgSplit[0] == 'add':
toDoList.append(msgSplit[1:])
elif msgSplit[0] == 'list':
resp.message(msgSplit[1:])
elif msgSplit[0] == 'remove':
deL = msgSplit[1]
if deL!=0:
del msgSplit[deL-1]
else:
del msgSplit[deL]
# Add a message
resp.message("Hi! It looks like your phone number was born in %s" %country)
return str(resp)
if __name__ == "__main__":
app.run(debug=True)
注意:您不能在stackoverflow的代码编辑器中打开链接。请复制代码并在您的编辑器中尝试
记住:您仍然可以通过RightClick-> OPenLinkInNewTab
打开链接