setTimeout () для отображения всплывающего окна через 10 секунд - PullRequest
0 голосов
/ 06 мая 2020

Я хочу показать сообщение об отправке WhatsApp через 10 секунд после загрузки страницы с помощью этого кода, но я не знаю, как объединить их оба.

window.onload = function() {
  setTimeout(function() {
    document.getElementById('mydiv').style.display = 'block';
  }, 10000);
}
$(function() {
  $('#WAButton').floatingWhatsApp({
    phone: '1231231231', //WhatsApp Business phone number International format-
    //Get it with Toky at https://toky.co/en/features/whatsapp.
    headerTitle: 'Chat with us on WhatsApp!', //Popup Title
    popupMessage: 'Hello, how can we help you?', //Popup Message
    showPopup: true, //Enables popup display
    buttonImage: '<img src="https://rawcdn.githack.com/rafaelbotazini/floating-whatsapp/3d18b26d5c7d430a1ab0b664f8ca6b69014aed68/whatsapp.svg" />', //Button Image
    //headerColor: 'crimson', //Custom header color
    //backgroundColor: 'crimson', //Custom background button color
    position: "right"    

  });
});

1 Ответ

0 голосов
/ 06 мая 2020

просто создайте функцию и вызовите ее по таймауту

function show_whatsapp_button(){
    $('#WAButton').floatingWhatsApp({
        phone: '1231231231', //WhatsApp Business phone number International format-
        //Get it with Toky at https://toky.co/en/features/whatsapp.
        headerTitle: 'Chat with us on WhatsApp!', //Popup Title
        popupMessage: 'Hello, how can we help you?', //Popup Message
        showPopup: true, //Enables popup display
        buttonImage: '<img src="https://rawcdn.githack.com/rafaelbotazini/floating-whatsapp/3d18b26d5c7d430a1ab0b664f8ca6b69014aed68/whatsapp.svg" />', //Button Image
        //headerColor: 'crimson', //Custom header color
        //backgroundColor: 'crimson', //Custom background button color
        position: "right"    

  });
  document.getElementById('mydiv').style.display = 'block';
}

window.onload = function() {
setTimeout(function() {
    show_whatsapp_button();
    }, 10000);
}
...