Super simple sharing.
Includes: QQ, QQ Space, Sina Weibo, Tencent Weibo, WeChat (just a QR code);
1. The first is the html code:
( I’m not very good at the front end, I’ve always used bootstrap)
1 <div class="col-sm-5 col-xs-5 btn btn-success img-fen"> 2 <a href="#" class="a-link " onclick="open_share('qq')"> 3 <img src="/static/imghwm/default1.png" data-src="~/Content/WapHomeicon/qq.png" class="lazy" / alt="HTML implementation is introduced with a simple sharing function" > 4 QQ好友 5 </a> 6 </div> 7 8 <div class="col-sm-5 col-xs-5 btn btn-success img-fen"> 9 <a href="#" class="a-link" data-toggle="modal" data-target="#myWeixin"> 10 <img src="/static/imghwm/default1.png" data-src="~/Content/WapHomeicon/weixin.png" class="lazy" / alt="HTML implementation is introduced with a simple sharing function" > 11 微信 12 </a> 13 </div> 14 <div class="col-sm-5 col-xs-5 btn btn-success img-fen"> 15 <a href="#" class="a-link" onclick="open_share('qzone')"> 16 <img src="/static/imghwm/default1.png" data-src="~/Content/WapHomeicon/qz.png" class="lazy" / alt="HTML implementation is introduced with a simple sharing function" > 17 QQ空间 18 </a> 19 </div> 20 <div class="col-sm-5 col-xs-5 btn btn-success img-fen"> 21 <a href="#" class="a-link" onclick="open_share('weibo')"> 22 <img src="/static/imghwm/default1.png" data-src="~/Content/WapHomeicon/weibo.png" class="lazy" / alt="HTML implementation is introduced with a simple sharing function" > 23 新浪微博 24 </a> 25 </div><!-- /.modal-content -->
1, and then the js code:
(WeChat is not included here,)
1 function open_share(type) { 2 var shareUrl = ‘http://www.baidu.com’; 3 var shareTitle = '自定义标题'; 4 var shareImg = 'http://s.jiathis.com/qrcode.php?url=' + shareUrl; 5 var shareDesc = '自定义内容'; 6 var openUrl = ''; 7 switch (type) { 8 case 'qzone': 9 openUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + shareUrl + '&title=' + shareTitle + '&pics=' + shareImg 12 break; 13 case 'weixin': 14 t_delay('请在微信客户端使用'); 15 return false; 16 break; 17 case 'qq': 18 openUrl = 'http://connect.qq.com/widget/shareqq/index.html?url=' + shareUrl + '&desc=' + shareDesc + ' &summary=' + shareDesc + '&site=' + shareUrl + '&pics=' + shareImg; 21 break; 22 case 'tqq': 23 openUrl = 'http://v.t.qq.com/share/share.php?title=' + shareTitle + '&url=' + shareUrl + '&site=' + shareUrl + '&pic=' + shareImg; 26 break; 27 case 'weibo': 28 openUrl = ' =' + shareUrl + '&title=' + shareTitle + '&&source=' + shareUrl + ' &sourceUrl=' + shareUrl + '&content=' + shareDesc + '&pic=' + shareImg; 33 break; 34 } 35 window.open(openUrl); }
3, Then the QR code pops up on WeChat:
(still using the bootstrap modal box)
1 <!-- 模态框(Modal) --> 2 <div class="modal fade" id="myWeixin" tabindex="-1" role="dialog" 3 aria-labelledby="myModalLabel" aria-hidden="true"> 4 <div class="modal-dialog" id="xian"> 5 <div class="modal-content"> 6 <div class="modal-header"> 7 <button type="button" class="close" data-dismiss="modal" 8 aria-hidden="true"> 9 × 10 </button> 11 <h4 class="modal-title" id="myModalLabel"> 12 用微信扫描二维码分享到朋友圈 13 </h4> 14 </div> 15 <div class="modal-body erweima"> 16 <img src="/static/imghwm/default1.png" data-src="http://s.jiathis.com/qrcode.php?url=http://www.baidu.com" class="lazy" alt="微信二维码" /> 19 </div> 20 <div class="modal-footer"> 21 <button type="button" class="btn btn-default" 22 data-dismiss="modal"> 23 关闭 24 </button> 25 </div> 26 </div><!-- /.modal-content --> 27 </div><!-- /.modal-dialog --> 28 </div><!-- /.modal -->
4. Finally, it is judged whether to open it in WeChat:
(from I picked it up from elsewhere. What I did here was to remove the QR code and modal box that originally popped up if it was opened in WeChat, and put a prompt picture with an arrow to allow users to share using WeChat. .)
1 //判断微信 2 function is_weixn(){ 3 var ua = navigator.userAgent.toLowerCase(); 4 if(ua.match(/MicroMessenger/i)=="micromessenger") { 5 $("div").remove("div[class=modal-content]"); 6 var $htmlLi = $('<img src="/static/imghwm/default1.png" data-src="~/Content/WapHomeicon/xian.png" class="lazy" style="max-width:90%" alt="xian"/>'); 7 8 //创建DOM对象 9 var $ul = $("#xian"); //获取UL对象 10 $ul.append($htmlLi); //将$htmlLi追加到$ul元素的li列表 11 12 } else { 13 //不是微信 14 } 15 }
The above is the detailed content of HTML implementation is introduced with a simple sharing function. For more information, please follow other related articles on the PHP Chinese website!

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
