资讯专栏INFORMATION COLUMN

Safari配置WebApp----添加启动图和桌面图标让你的WebApp在ios设备上体验如原生一

zoomdong / 1042人阅读

摘要:然后使用状态栏样式标签来根据您的应用程序需要更改状态栏的外观。这是我在项目上添加的代码实际体验如下图所示可以看到用户添加到主屏幕后,有了自定义的图标及启动图,打开后也不会有的地址栏和工具栏,体验跟原生一样。

现在很多开发者的Web应用程序的设计样式和交互类似本机应用程序,例如,它的缩放比例适合iOS上的整个屏幕。当用户将其添加到主屏幕时,您可以通过使其看起来像本机应用程序一样,在iOS上为您的Web应用程序定制Safari。您可以使用其他平台忽略的iOS设置来执行此操作。

例如,您可以为添加到iOS主屏幕时用于表示Web应用程序的图标指定图标,如指定Web Clip的网页图标所述。当您的Web应用程序从主屏幕启动时,您还可以最小化iOS用户界面上的Safari,如更改状态栏外观和隐藏Safari用户界面组件(搜索栏及工具栏)。这些都是可选设置,添加到您的网页内容时会被其他平台忽略。

阅读Web应用程序的“视口设置”,了解如何在iOS上设置Web应用程序的视口。

指定Web应用程序的网页图标

您可能希望用户能够将您的Web应用程序或网页链接添加到ios设备主屏幕。这些由图标表示的链接称为Web剪辑。遵循这些简单的步骤来指定一个图标来表示您的iOS应用程序或网页。

要为整个网站(网站上的每个页面)指定一个图标,请将一个图标文件以PNG格式放置在名为root的文档文件夹 apple-touch-icon.png
要为单个网页指定一个图标或者将网站图标替换为网页特定的图标,请向该网页添加一个链接元素,如下所示:


在上面的例子中,custom_icon.png用你的图标文件名替换。
要为不同的设备分辨率指定多个图标(例如,同时支持iPhone和iPad设备),请sizes按以下方式为每个链接元素添加一个属性:





使用最适合设备的图标。有关当前图标大小和建议,请参阅iOS人机界面指南的“图形”一章。
如果没有与设备的建议尺寸相匹配的图标,则会使用大于推荐尺寸的最小图标。如果没有大于推荐尺寸的图标,则使用最大的图标。

如果没有使用链接元素指定图标,则会在网站根目录中搜索带有apple-touch-icon...前缀的图标。例如,如果设备的适当图标大小为58 x 58,系统将按以下顺序搜索文件名:

apple-touch-icon-80x80.png

apple-touch-icon.png

注意: iOS 7上的Safari不会为图标添加效果。老版本的Safari不会为使用-precomposed.png后缀命名的图标文件添加效果。有关详细信息,请参阅第一步:在iTunes Connect中识别您的应用程序。

指定启动屏幕图像

在iOS上,与原生应用程序类似,您可以指定在Web应用程序启动时显示的启动屏幕图像。当您的Web应用程序处于脱机状态时,这非常有用。默认情况下,使用上次启动时的Web应用程序屏幕截图。要设置另一个启动图像,请在网页中添加一个链接元素,如下所示:


在上面的例子中,launch.png用你的启动屏幕文件名替换。有关当前的启动屏幕大小和建议,请参阅iOS人机界面指南的“图形”一章。

添加启动图标标题

在iOS上,您可以为启动图标指定一个Web应用程序标题。默认情况下,使用标签。要设置不同的标题,请在网页中添加元标记,如下所示:</p> <pre><meta name =“apple-mobile-web-app-title”content =“AppTitle”> </pre> <p>在上面的例子中,替换AppTitle你的标题。</p> <b>隐藏Safari用户界面组件</b> <p>在iOS上,作为优化您的Web应用程序的一部分,让它使用独立模式更像本地应用程序。当您使用此独立模式时,Safari不会用于显示Web内容 - 具体来说,屏幕顶部没有浏览器URL文本字段,或者屏幕底部没有按钮栏。只有一个状态栏出现在屏幕的顶部。阅读更改状态栏外观以了解如何最小化状态栏。</p> <p>将apple-mobile-web-app-capable元标记设置yes为打开独立模式。例如,以下HTML将使用独立模式显示Web内容。</p> <pre><meta name =“apple-mobile-web-app-capable”content =“yes”> </pre> <p>您可以使用window.navigator.standalone只读布尔JavaScript属性确定网页是否以独立模式显示。有关独立模式的更多信息,请参阅apple-mobile-web-app-capable。</p> <b>更改状态栏的外观</b> <p>如果您的Web应用程序以独立模式显示,如本机应用程序,则可以最小化iOS上屏幕顶部显示的状态栏。这样做使用状态栏式元标记。</p> <p>除非您首先指定了隐藏Safari用户界面组件中所述的独立模式,否则此元标记将不起作用。然后使用状态栏样式meta标签apple-mobile-web-app-status-bar-style来根据您的应用程序需要更改状态栏的外观。例如,如果要使用整个屏幕,请将状态栏样式设置为半透明黑色。</p> <p>例如,下面的HTML将状态栏的背景颜色设置为黑色:</p> <pre><meta name =“apple-mobile-web-app-status-bar-style”content =“black”> </pre> <p>有关状态栏外观的更多信息,请参阅iOS人机界面指南的“UI栏”一章。</p> <b>链接到其他原生应用程序</b> <p>您的Web应用程序可以通过创建具有特殊URL的链接来链接到其他内置的iOS应用程序。可用的功能包括拨打电话号码,发送短信或iMessage,并在其本机应用程序(如果已安装)中打开YouTube视频。例如,要链接到电话号码,请按以下格式构造一个锚点元素:</p> <pre><a href="tel:1-408-555-5555">给我打电话</a> </pre> <p>有关这些功能的完整视图,请参阅Apple URL Scheme Reference。</p> <p>这是我在项目index.html上添加的代码:</p> <pre><!-- Specifying a Webpage Icon for Web Clip for Safari --> <link rel="apple-touch-icon" href="assets/imgs/logo.png"> <!-- Specifying a Launch Screen Image for Safari --> <link rel="apple-touch-startup-image" href="assets/imgs/splash.png"> <!-- Hiding Safari User Interface Components --> <meta name="apple-mobile-web-app-capable" content="yes"> <!-- Changing the Status Bar Appearance --> <meta name="apple-mobile-web-app-status-bar-style" content="black"> </pre> <p>实际体验如下图所示:<br><script type="text/javascript">showImg("https://segmentfault.com/img/bV2Mrz?w=283&h=500");</script></p> <p>可以看到用户添加到主屏幕后,有了自定义的图标及启动图,打开webapp后也不会有safari的地址栏和工具栏,体验跟原生一样。<br>因为我使用iphone自带的屏幕录制功能,所以顶部状态栏背景被占用,实际体验启动图是全屏的。</p> </div> <div class="mt-64 tags-seach" > <div class="tags-info"> <a style="width:120px;" title="idc机房托管" href="https://www.ucloud.cn/site/product/uxzone.html">idc机房托管</a> <a style="width:120px;" title="私有云" href="https://www.ucloud.cn/site/product/ucloudstack.html">私有云</a> <a style="width:120px;" title="WebApp" href="https://www.ucloud.cn/yun/tag/WebApp/">WebApp</a> <a style="width:120px;" title="webapp 5" href="https://www.ucloud.cn/yun/tag/webapp 5/">webapp 5</a> <a style="width:120px;" title="webrtc webapp" href="https://www.ucloud.cn/yun/tag/webrtc webapp/">webrtc webapp</a> <a style="width:120px;" title="webapp mailto" href="https://www.ucloud.cn/yun/tag/webapp mailto/">webapp mailto</a> </div> </div> <div class="entry-copyright mb-30"> <p class="mb-15"> 文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。</p> <p>转载请注明本文地址:https://www.ucloud.cn/yun/16943.html</p> </div> <ul class="pre-next-page"> <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/16942.html">上一篇:玩转CocoaPods</a></li> <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/16944.html">下一篇:Android程序员学IOS-UI篇</a></li> </ul> </div> <div class="about_topicone-mid"> <h3 class="top-com-title mb-0"><span data-id="0">相关文章</span></h3> <ul class="com_white-left-mid atricle-list-box"> <li> <div class="atricle-list-right"> <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/51754.html"><b><em>Safari</em><em>配置</em><em>WebApp</em>----<em>添加</em><em>启动</em><em>图和</em><em>桌面</em><em>图标</em><em>让<em>你的</em></em><em>WebApp</em><em>在</em><em>ios</em><em>设备</em><em>上体</em><em>验如</em><em>原生</em><em>一</em></b></a></h2> <p class="ellipsis2 good">摘要:然后使用状态栏样式标签来根据您的应用程序需要更改状态栏的外观。这是我在项目上添加的代码实际体验如下图所示可以看到用户添加到主屏幕后,有了自定义的图标及启动图,打开后也不会有的地址栏和工具栏,体验跟原生一样。 现在很多开发者的Web应用程序的设计样式和交互类似本机应用程序,例如,它的缩放比例适合iOS上的整个屏幕。当用户将其添加到主屏幕时,您可以通过使其看起来像本机应用程序一样,在iOS...</p> <div class="com_white-left-info"> <div class="com_white-left-infol"> <a href="https://www.ucloud.cn/yun/u-1463.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/14/small_000001463.jpg" alt=""><span class="layui-hide64">lindroid</span></a> <time datetime="">2019-08-01 18:28</time> <span><i class="fa fa-commenting"></i>评论0</span> <span><i class="fa fa-star"></i>收藏0</span> </div> </div> </div> </li> <li> <div class="atricle-list-right"> <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/96439.html"><b>【PWA学习与实践】(2) 使用Manifest,<em>让<em>你的</em></em><em>WebApp</em>更“Native”</b></a></h2> <p class="ellipsis2 good">摘要:,不过在上会导致状态栏不显示任何东西。下面是项目中的相关设置图书搜索中的处理方式与类似,中也有自己的标签来指示相应的资源。 《PWA学习与实践》系列文章已整理至gitbook - PWA学习手册,文字内容已同步至learning-pwa-ebook。转载请注明作者与出处。 本文是《PWA学习与实践》系列的第二篇文章。文中的代码都可以在learning-pwa的manifest分支上找到...</p> <div class="com_white-left-info"> <div class="com_white-left-infol"> <a href="https://www.ucloud.cn/yun/u-1369.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/13/small_000001369.jpg" alt=""><span class="layui-hide64">flyer_dev</span></a> <time datetime="">2019-08-23 10:32</time> <span><i class="fa fa-commenting"></i>评论0</span> <span><i class="fa fa-star"></i>收藏0</span> </div> </div> </div> </li> <li> <div class="atricle-list-right"> <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/58078.html"><b>【PWA学习与实践】(2) 使用Manifest,<em>让<em>你的</em></em><em>WebApp</em>更“Native”</b></a></h2> <p class="ellipsis2 good">摘要:,不过在上会导致状态栏不显示任何东西。下面是项目中的相关设置图书搜索中的处理方式与类似,中也有自己的标签来指示相应的资源。 《PWA学习与实践》系列文章已整理至gitbook - PWA学习手册,文字内容已同步至learning-pwa-ebook。转载请注明作者与出处。 本文是《PWA学习与实践》系列的第二篇文章。文中的代码都可以在learning-pwa的manifest分支上找到...</p> <div class="com_white-left-info"> <div class="com_white-left-infol"> <a href="https://www.ucloud.cn/yun/u-373.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/03/small_000000373.jpg" alt=""><span class="layui-hide64">solocoder</span></a> <time datetime="">2019-08-05 14:32</time> <span><i class="fa fa-commenting"></i>评论0</span> <span><i class="fa fa-star"></i>收藏0</span> </div> </div> </div> </li> <li> <div class="atricle-list-right"> <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/55469.html"><b>html5手机页面的那些meta</b></a></h2> <p class="ellipsis2 good">摘要:如针对搜索引擎的,文档的字符编码,设置刷新缓存等。标准模式指令以标准模式显示,而模式指令以模式显示。竖屏标准分辨率竖屏横屏标准分辨率横屏和的启动画面是包含状态栏区域的。 一、普通手机页的设置1.说明:屏幕的缩放 content的几个属性: width viewport的宽度[device-width | pixel_value]width如果直接设置pixel_value数值,大部分的...</p> <div class="com_white-left-info"> <div class="com_white-left-infol"> <a href="https://www.ucloud.cn/yun/u-1140.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/11/small_000001140.jpg" alt=""><span class="layui-hide64">ivyzhang</span></a> <time datetime="">2019-08-02 18:37</time> <span><i class="fa fa-commenting"></i>评论0</span> <span><i class="fa fa-star"></i>收藏0</span> </div> </div> </div> </li> <li> <div class="atricle-list-right"> <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/86620.html"><b>2017前端技术预览(未完结,最后更新于1月13日)</b></a></h2> <p class="ellipsis2 good">摘要:图离线情况下发送微信消息,等网络正常后微信会继续处理我们的消息。无论是在微信中还是手机短信,在没有信号时都不影响我们编辑发送短信,等网络恢复时会自动帮我们把之前编辑好的信息顺利递送出去。 (删掉了第一小段,因为和内容关系不大。。) 本来这该是个技术分享会的内容,参加完 Google Developer Day(GDD) 后想做个 AI Demo 来分享,奈何技术实力不够,害怕把大家带进...</p> <div class="com_white-left-info"> <div class="com_white-left-infol"> <a href="https://www.ucloud.cn/yun/u-720.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/07/small_000000720.jpg" alt=""><span class="layui-hide64">cnio</span></a> <time datetime="">2019-08-21 11:22</time> <span><i class="fa fa-commenting"></i>评论0</span> <span><i class="fa fa-star"></i>收藏0</span> </div> </div> </div> </li> </ul> </div> <div class="topicone-box-wangeditor"> <h3 class="top-com-title mb-64"><span>发表评论</span></h3> <div class="xcp-publish-main flex_box_zd"> <div class="unlogin-pinglun-box"> <a href="javascript:login()" class="grad">登陆后可评论</a> </div> </div> </div> <div class="site-box-content"> <div class="site-content-title"> <h3 class="top-com-title mb-64"><span>0条评论</span></h3> </div> <div class="pages"></ul></div> </div> </div> <div class="layui-col-md4 layui-col-lg3 com_white-right site-wrap-right"> <div class=""> <div class="com_layuiright-box user-msgbox"> <a href="https://www.ucloud.cn/yun/u-149.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/01/small_000000149.jpg" alt=""></a> <h3><a href="https://www.ucloud.cn/yun/u-149.html" rel="nofollow">zoomdong</a></h3> <h6>男<span>|</span>高级讲师</h6> <div class="flex_box_zd user-msgbox-atten"> <a href="javascript:attentto_user(149)" id="attenttouser_149" class="grad follow-btn notfollow attention">我要关注</a> <a href="javascript:login()" title="发私信" >我要私信</a> </div> <div class="user-msgbox-list flex_box_zd"> <h3 class="hpf">TA的文章</h3> <a href="https://www.ucloud.cn/yun/ut-149.html" class="box_hxjz">阅读更多</a> </div> <ul class="user-msgbox-ul"> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/124539.html">面试官:系统需求多变时如何设计?</a></h3> <p>阅读 1481<span>·</span>2021-11-23 09:51</p></li> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/121175.html">阿里云安骑士卸载:安骑士、云盾、云监控,一键卸载脚本FuckAliyun</a></h3> <p>阅读 2779<span>·</span>2021-09-26 10:21</p></li> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/119616.html">软件接口测试工具Jmeter使用核心详解【建议收藏】</a></h3> <p>阅读 617<span>·</span>2021-09-09 09:32</p></li> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/113525.html">JS正则表达式</a></h3> <p>阅读 743<span>·</span>2019-08-29 16:06</p></li> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/110748.html">深入浅出Mysql索引的那些事儿</a></h3> <p>阅读 2920<span>·</span>2019-08-27 14:27</p></li> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/109139.html">原生JS如何获取当前元素属于父元素第几个子元素</a></h3> <p>阅读 3104<span>·</span>2019-08-26 13:36</p></li> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/106865.html">你不知道的this</a></h3> <p>阅读 612<span>·</span>2019-08-26 10:56</p></li> <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/106701.html">vue中使用echarts</a></h3> <p>阅读 2460<span>·</span>2019-08-26 10:44</p></li> </ul> </div> <!-- 云社区相关服务 --> <div class="com_layuiright-box"> <h3 class="top-com-title"><span>云社区相关服务</span></h3> <div class="community-box flex_box flex_wrap community-box1"> <a href="https://www.ucloud.cn/yun/question/add.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/static/theme/ukd/images/topicone-icon1.png" alt="提问"> <span>提问</span> </a> <a href="https://www.ucloud.cn/yun/article" rel="nofollow"> <img src="https://www.ucloud.cn/yun/static/theme/ukd/images/topicone-icon2.png" alt="学习"> <span>学习</span> </a> <a href="https://www.ucloud.cn/yun/user/vertify.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/static/theme/ukd/images/topicone-icon4.png" alt="认证"> <span>认证</span> </a> <a href="https://www.ucloud.cn/site/product/uhost.html?ytag=seo" rel="nofollow"> <img src="https://www.ucloud.cn/yun/static/theme/ukd/images/topicone-icon5.png" alt="产品"> <span>产品</span> </a> <a href="https://spt.ucloud.cn/30001?ytag=seo" rel="nofollow"> <img src="https://www.ucloud.cn/yun/static/theme/ukd/images/topicone-icon6.png" alt="技术服务"> <span>技术服务</span> </a> <a href="https://spt.ucloud.cn/30001?ytag=seo" rel="nofollow"> <img src="https://www.ucloud.cn/yun/static/theme/ukd/images/topicone-icon3.png" alt="售前咨询"> <span>售前咨询</span> </a> </div> </div> <!-- 文章详情右侧广告--> <div class="com_layuiright-box"> <h6 class="top-com-title"><span>最新活动</span></h6> <div class="com_adbox"> <div class="layui-carousel" id="right-item"> <div carousel-item> <div> <a href="https://www.ucloud.cn/site/product/uhost.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/data/attach/220620/Z7TLrpAi.png" alt="云服务器"> </a> </div> <div> <a href="https://www.ucloud.cn/site/product/uhybrid.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/data/attach/220620/MWraMsBh.png" alt="混合云"> </a> </div> <div> <a href="https://www.ucloud.cn/site/product/ucloudstack.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/data/attach/220620/ifzOxvjW.png" alt="私有云"> </a> </div> <div> <a href="https://www.ucloud.cn/site/product/utrion.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/data/attach/220620/VDqwC1iN.png" alt="超融合服务器"> </a> </div> <div> <a href="https://www.ucloud.cn/site/product/uhybrid.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/data/attach/220630/pJwnviKN.png" alt="服务器托管"> </a> </div> <div> <a href="https://www.ucloud.cn/site/product/uxzone.html" rel="nofollow"> <img src="https://www.ucloud.cn/yun/data/attach/220630/CDb5uXxp.jpeg" alt="idc机房托管"> </a> </div> <div> <a href="https://www.ucloud.cn/site/active/network.html?ytag=seo" rel="nofollow"> <img src="https://www.ucloud.cn/yun/data/attach/230227/XWsSXmvm.png" alt="专线服务"> </a> </div> </div> </div> </div> <!-- banner结束 --> <div class="adhtml"> </div> <script> $(function(){ $.ajax({ type: "GET", url:"https://www.ucloud.cn/yun/ad/getad/1.html", cache: false, success: function(text){ $(".adhtml").html(text); } }); }) </script> </div> </div> </div> </div> </div> </section> <!-- wap拉出按钮 --> <div class="site-tree-mobile layui-hide"> <i class="layui-icon layui-icon-spread-left"></i> </div> <!-- wap遮罩层 --> <div class="site-mobile-shade"></div> <!--付费阅读 --> <div id="payread"> <div class="layui-form-item">阅读需要支付1元查看</div> <div class="layui-form-item"><button class="btn-right">支付并查看</button></div> </div> <script> var prei=0; $(".site-seo-depict pre").each(function(){ var html=$(this).html().replace("<code>","").replace("</code>","").replace('<code class="javascript hljs" codemark="1">',''); $(this).attr('data-clipboard-text',html).attr("id","pre"+prei); $(this).html("").append("<code>"+html+"</code>"); prei++; }) $(".site-seo-depict img").each(function(){ if($(this).attr("src").indexOf('data:image/svg+xml')!= -1){ $(this).remove(); } }) $("LINK[href*='style-49037e4d27.css']").remove(); $("LINK[href*='markdown_views-d7a94ec6ab.css']").remove(); layui.use(['jquery', 'layer','code'], function(){ $("pre").attr("class","layui-code"); $("pre").attr("lay-title",""); $("pre").attr("lay-skin",""); layui.code(); $(".layui-code-h3 a").attr("class","copycode").html("复制代码 ").attr("onclick","copycode(this)"); }); function copycode(target){ var id=$(target).parent().parent().attr("id"); var clipboard = new ClipboardJS("#"+id); clipboard.on('success', function(e) { e.clearSelection(); alert("复制成功") }); clipboard.on('error', function(e) { alert("复制失败") }); } //$(".site-seo-depict").html($(".site-seo-depict").html().slice(0, -5)); </script> <link rel="stylesheet" type="text/css" href="https://www.ucloud.cn/yun/static/js/neweditor/code/styles/tomorrow-night-eighties.css"> <script src="https://www.ucloud.cn/yun/static/js/neweditor/code/highlight.pack.js" type="text/javascript"></script> <script src="https://www.ucloud.cn/yun/static/js/clipboard.js"></script> <script>hljs.initHighlightingOnLoad();</script> <script> function setcode(){ var _html=''; document.querySelectorAll('pre code').forEach((block) => { var _tmptext=$.trim($(block).text()); if(_tmptext!=''){ _html=_html+_tmptext; console.log(_html); } }); } </script> <script> function payread(){ layer.open({ type: 1, title:"付费阅读", shadeClose: true, content: $('#payread') }); } // 举报 function jupao_tip(){ layer.open({ type: 1, title:false, shadeClose: true, content: $('#jubao') }); } $(".getcommentlist").click(function(){ var _id=$(this).attr("dataid"); var _tid=$(this).attr("datatid"); $("#articlecommentlist"+_id).toggleClass("hide"); var flag=$("#articlecommentlist"+_id).attr("dataflag"); if(flag==1){ flag=0; }else{ flag=1; //加载评论 loadarticlecommentlist(_id,_tid); } $("#articlecommentlist"+_id).attr("dataflag",flag); }) $(".add-comment-btn").click(function(){ var _id=$(this).attr("dataid"); $(".formcomment"+_id).toggleClass("hide"); }) $(".btn-sendartcomment").click(function(){ var _aid=$(this).attr("dataid"); var _tid=$(this).attr("datatid"); var _content=$.trim($(".commenttext"+_aid).val()); if(_content==''){ alert("评论内容不能为空"); return false; } var touid=$("#btnsendcomment"+_aid).attr("touid"); if(touid==null){ touid=0; } addarticlecomment(_tid,_aid,_content,touid); }) $(".button_agree").click(function(){ var supportobj = $(this); var tid = $(this).attr("id"); $.ajax({ type: "GET", url:"https://www.ucloud.cn/yun/index.php?topic/ajaxhassupport/" + tid, cache: false, success: function(hassupport){ if (hassupport != '1'){ $.ajax({ type: "GET", cache:false, url: "https://www.ucloud.cn/yun/index.php?topic/ajaxaddsupport/" + tid, success: function(comments) { supportobj.find("span").html(comments+"人赞"); } }); }else{ alert("您已经赞过"); } } }); }); function attenquestion(_tid,_rs){ $.ajax({ //提交数据的类型 POST GET type:"POST", //提交的网址 url:"https://www.ucloud.cn/yun/favorite/topicadd.html", //提交的数据 data:{tid:_tid,rs:_rs}, //返回数据的格式 datatype: "json",//"xml", "html", "script", "json", "jsonp", "text". //在请求之前调用的函数 beforeSend:function(){}, //成功返回之后调用的函数 success:function(data){ var data=eval("("+data+")"); console.log(data) if(data.code==2000){ layer.msg(data.msg,function(){ if(data.rs==1){ //取消收藏 $(".layui-layer-tips").attr("data-tips","收藏文章"); $(".layui-layer-tips").html('<i class="fa fa-heart-o"></i>'); } if(data.rs==0){ //收藏成功 $(".layui-layer-tips").attr("data-tips","已收藏文章"); $(".layui-layer-tips").html('<i class="fa fa-heart"></i>') } }) }else{ layer.msg(data.msg) } } , //调用执行后调用的函数 complete: function(XMLHttpRequest, textStatus){ postadopt=true; }, //调用出错执行的函数 error: function(){ //请求出错处理 postadopt=false; } }); } </script> <footer> <div class="layui-container"> <div class="flex_box_zd"> <div class="left-footer"> <h6><a href="https://www.ucloud.cn/"><img src="https://www.ucloud.cn/yun/static/theme/ukd//images/logo.png" alt="UCloud (优刻得科技股份有限公司)"></a></h6> <p>UCloud (优刻得科技股份有限公司)是中立、安全的云计算服务平台,坚持中立,不涉足客户业务领域。公司自主研发IaaS、PaaS、大数据流通平台、AI服务平台等一系列云计算产品,并深入了解互联网、传统企业在不同场景下的业务需求,提供公有云、混合云、私有云、专有云在内的综合性行业解决方案。</p> </div> <div class="right-footer layui-hidemd"> <ul class="flex_box_zd"> <li> <h6>UCloud与云服务</h6> <p><a href="https://www.ucloud.cn/site/about/intro/">公司介绍</a></p> <p><a href="https://zhaopin.ucloud.cn/" >加入我们</a></p> <p><a href="https://www.ucloud.cn/site/ucan/onlineclass/">UCan线上公开课</a></p> <p><a href="https://www.ucloud.cn/site/solutions.html" >行业解决方案</a></p> <p><a href="https://www.ucloud.cn/site/pro-notice/">产品动态</a></p> </li> <li> <h6>友情链接</h6> <p><a href="https://www.surfercloud.com/">SurferCloud</a></p> <p><a href="https://ucloudstack.com/" >私有云</a></p><p><a href="https://pinex.it" >pinex</a></p> <p><a href="https://www.renyucloud.com/" ></a></p> <p><a href="https://www.picpik.ai" >AI Art Generator</a></p> <p><a href="https://www.uwin-link.com" >工厂仿真软件</a></p> </li> <li> <h6>社区栏目</h6> <p><a href="https://www.ucloud.cn/yun/column/index.html">专栏文章</a></p> <p><a href="https://www.ucloud.cn/yun/ask/">专业问答</a></p> <p><a href="https://www.ucloud.cn/yun/kc.html">云学院</a></p> <p><a href="https://www.ucloud.cn/yun/udata/">专题地图</a></p> </li> <li> <h6>常见问题</h6> <p><a href="https://www.ucloud.cn/site/ucsafe/notice.html" >安全中心</a></p> <p><a href="https://www.ucloud.cn/site/about/news/recent/" >新闻动态</a></p> <p><a href="https://www.ucloud.cn/site/about/news/report/">媒体动态</a></p> <p><a href="https://www.ucloud.cn/site/cases.html">客户案例</a></p> <p><a href="https://www.ucloud.cn/site/notice/">公告</a></p> </li> <li> <span><img src="https://static.ucloud.cn/7a4b6983f4b94bcb97380adc5d073865.png" alt="优刻得"></span> <p>扫扫了解更多</p></div> </div> <div class="copyright">Copyright © 2012-2023 UCloud 优刻得科技股份有限公司<i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/">沪公网安备 31011002000058号</a><i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/"></a> 沪ICP备12020087号-3</a><i>|</i> <script type="text/javascript" src="https://gyfk12.kuaishang.cn/bs/ks.j?cI=197688&fI=125915" charset="utf-8"></script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?290c2650b305fc9fff0dbdcafe48b59d"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-DZSMXQ3P9N"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-DZSMXQ3P9N'); </script> <script> (function(){ var el = document.createElement("script"); el.src = "https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?99f50ea166557aed914eb4a66a7a70a4709cbb98a54ecb576877d99556fb4bfc3d72cd14f8a76432df3935ab77ec54f830517b3cb210f7fd334f50ccb772134a"; el.id = "ttzz"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(el, s); })(window) </script></div> </div> </footer> </body> <script src="https://www.ucloud.cn/yun/static/theme/ukd/js/common.js"></script> <<script type="text/javascript"> $(".site-seo-depict *,.site-content-answer-body *,.site-body-depict *").css("max-width","100%"); </script> </html>