某人剛行進在移動前端開發的道路上,一日:
使用工具(平臺):iphone andriod 微信中打開網頁;
需求:打開網頁後,需要動態根據後端傳回的數據再次修改頁面中的內容(包括:背景、Logo、title。。。。);
問題:使用iphone打開後,title不能替換;
代碼(解決方案):
setInterval(function(){
<span style="white-space:pre"> </span>var $body = $('body');
<span style="white-space:pre"> </span>document.title= Math.random();
<span style="white-space:pre"> </span>var $iframe = $('<iframe src="favicon.ico"><iframe>');
<span style="white-space:pre"> </span>$iframe.on('load',function(){
<span style="white-space:pre"> </span>setTimeout(function(){
<span style="white-space:pre"> </span>$iframe.off('load').remove();
<span style="white-space:pre"> </span>},0);
<span style="white-space:pre"> </span>}).appendTo($body);
<span style="white-space:pre"> </span>},1000);
條件:預先加載JQ;
原理及推論:未搜到好的方案,從羣友(***菜***)處得到(感激莫名),還未仔細研究(demo還不造怎麼上傳,親測可以iphone5s)~