📌  相关文章
📜  如何在网站上添加whatsapp分享按钮?

📅  最后修改于: 2021-09-02 05:01:25             🧑  作者: Mango

WhatsApp 是最受欢迎的消息应用程序。本文介绍了如何在您的网站中添加 WhatsApp 分享按钮。

注意:这仅在安装了 WhatsApp 的移动设备中打开网站时才有效。

第 1 步:设计一个带有超链接的简单网页。当用户单击此链接时,将完成共享。

HTML


  

    
  
    
        How to add WhatsApp share 
        button on website?
    

  

    

Whatsapp sharing

       Share to whatsapp   


HTML


  

    
    
  
    
        How to add WhatsApp share
        button on website?
    
  
    

  

    

Whatsapp sharing

                Share to whatsapp        


HTML


  

    
  
    
  
    
        How to add whatsapp share 
        button on website?
    
  
    

  

    

Whatsapp sharing

                                   


第 2 步:这在桌面\笔记本电脑上不起作用,所以让我们添加 CSS 以将其隐藏在大屏幕上。为此,使用 CSS @media 查询。


例1:本例是通过以上两步实现的。请注意 href 属性指定位置,并且此请求将发送到 WhatsApp 应用程序。

句法:

href="whatsapp://send?text=Your message here"

HTML



  

    
    
  
    
        How to add WhatsApp share
        button on website?
    
  
    

  

    

Whatsapp sharing

                Share to whatsapp        

保存此文件并在手机中打开。

输出:

示例 2:在此示例中,我们将从用户获取输入并使用 JavaScript 发送该消息。在这个例子中,我们定义了一个类来仅在移动设备上显示内容。

HTML



  

    
  
    
  
    
        How to add whatsapp share 
        button on website?
    
  
    

  

    

Whatsapp sharing

                                   

输出: