如何在你的WordPress网站即可查看天气预报,更快的得到天气情报!
相关实现原理
通过JavaScript代码调用相关天气2api接口,并且显示在DIY容器里面!
外观→小工具→自定义html
拖到你想要的位置-把这段代码复制进去就可以在网站查看天气预报啦!
HTML代码
<div id="tp-weather-widget"></div><script> (function(a,h,g,f,e,d,c,b){b=function(){d=h.createElement(g);c=h.getElementsByTagName(g)[0];d.src=e;d.charset="utf-8";d.async=1;c.parentNode.insertBefore(d,c)};a["SeniverseWeatherWidgetObject"]=f;a[f]||(a[f]=function(){(a[f].q=a[f].q||[]).push(arguments)});a[f].l=+new Date();if(a.attachEvent){a.attachEvent("onload",b)}else{a.addEventListener("load",b,false)}}(window,document,"script","SeniverseWeatherWidget","//cdn.sencdn.com/widget2/static/js/bundle.js?t="+parseInt((new Date().getTime() / 100000000).toString(),10))); window.SeniverseWeatherWidget('show', { flavor: "slim", location: "WX4FBXXFKE4F", geolocation: true, language: "zh-Hans", unit: "c", theme: "auto", token: "6cc2a314-5422-4e9c-b3ad-7b9217f4e494", hover: "enabled", container: "tp-weather-widget" }) </script> <p>点击<em><span style="color: #ff6600;"><strong>天气温度</strong></span></em>可以查看详情!</p>
最新评论