宇宙無敵大將 "司徒正美說"javascript
https://github.com/RubyLouvre/mobileTechcss
A useful tools or tips list for mobile web application developinghtml
這個項目收集移動端開發所須要的一些資源與小技巧html5
一些很是重要的工具類網站java
html5與css3技術應用評估node
各類奇妙的hackandroid
ios端移動設備參數速查css3
瀏覽器兼容表git
resize添加到收藏夾後,可直接在瀏覽器中出現各類分辨率的選擇工具來查看不一樣分辨率下的頁面效果http://beta.screenqueri.es/ http://responsivepx.com http://www.responsinator.com/ http://resizemybrowser.com/https://quirktools.com/screenfly/
http://blog.forecast.io/its-not-a-web-app-its-an-app-you-install-from-the-web/ http://lyric.im/best-practice-for-web-app-development/
http://www.cnblogs.com/pifoo/archive/2011/05/23/webkit-touch-event-1.html
http://www.cnblogs.com/pifoo/archive/2011/05/22/webkit-touch-event-2.html
http://www.cnblogs.com/pifoo/archive/2011/05/22/webkit-touch-event-3.html
meta標籤,這些meta標籤在開發webapp時起到很是重要的做用
第一個meta標籤表示:強制讓文檔的寬度與設備的寬度保持1:1,而且文檔最大的寬度比例是1.0,且不容許用戶點擊屏幕放大瀏覽; 尤爲要注意的是content裏多個屬性的設置必定要用分號+空格來隔開,若是不規範將不會起做用。
注意根據public_00提供的資料補充,content使用分號做爲分隔,在老的瀏覽器是支持的,但不是規範寫法。 規範的寫法應該是使用逗號分隔,參考http://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariHTMLRef/Articles/MetaTags.html http://developer.android.com/guide/webapps/targeting.html
其中:
在設置了initial-scale=1 以後,咱們終於能夠以1:1 的比例進行頁面設計了。 關於viewport,還有一個很重要的概念是:iphone 的safari 瀏覽器徹底沒有滾動條,並且不是簡單的「隱藏滾動條」, 是根本沒有這個功能。iphone 的safari 瀏覽器實際上從一開始就完整顯示了這個網頁,而後用viewport 查看其中的一部分。 當你用手指拖動時,其實拖的不是頁面,而是viewport。瀏覽器行爲的改變不止是滾動條,交互事件也跟普通桌面不同。 (請參考:指尖的下JS 系列文章)
對於a標記的點擊導航,默認是在onclick事件中處理的。而移動客戶端對onclick的響應相比PC瀏覽器有着明顯的幾百毫秒延遲。
在移動瀏覽器中對觸摸事件的響應順序應當是:
ontouchstart -> ontouchmove -> ontouchend -> onclick
所以,若是確實要加快對點擊事件的響應,就應當綁定ontouchend事件。
使用click會出現綁定點擊區域閃一下的狀況,解決:給該元素一個樣式以下
-webkit-tap-highlight-color: rgba(0,0,0,0);
若是不使用click,也不能簡單的用touchstart或touchend替代,須要用touchstart的模擬一個click事件,而且不能發生touchmove事件,或者用zepto中的tap(輕擊)事件。
body { -webkit-overflow-scrolling: touch; }
用iphone或ipad瀏覽很長的網頁滾動時的滑動效果很不錯吧?不過若是是一個div,而後設置
height:200px;overflow:auto;
的話,能夠滾動可是徹底沒有那滑動效果,很鬱悶吧? 我看到不少網站爲了實現這一效果,用了第三方類庫,最經常使用的是iscroll(包括新浪手機頁,百度等) 我一開始也使用,不過自從用了-webkit-overflow-scrolling: touch;樣式後,就徹底能夠拋棄第三方類庫了,把它加在body{}區域,全部的overflow須要滾動的均可以生效了。
詳見 http://johanbrook.com/browsers/native-momentum-scrolling-ios-5/ 頁面描述
<link rel="apple-touch-icon-precomposed" href="http://www.xxx.com/App_icon_114.png" /> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://www.xxx.com/App_icon_72.png" /> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://www.xxx.com/App_icon_114.png" />
這個屬性是當用戶把鏈接保存到手機桌面時使用的圖標,若是不設置,則會用網頁的截圖。有了這,就可讓你的網頁像APP同樣存在手機裏了
<link rel="apple-touch-startup-image" href="/img/startup.png" />
這個是APP啓動畫面圖片,用途和上面的相似,若是不設置,啓動畫面就是白屏,圖片像素就是手機全屏的像素
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
這個描述是表示打開的web app的最上面的時間、信號欄是黑色的,固然也能夠設置其它參數,詳細參數說明在:
<meta name="apple-touch-fullscreen" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
這2個描述也頗有用的,若是沒有它,你的web app會用safari瀏覽器打開,有了它,就會用獨立進程的無地址欄的打開,徹底能夠和普通的APP比擬了
下面還有個不錯的css,是用來區分視網膜屏幕的,這樣你能夠在iphone這樣的手機裏載入2x的圖片,就不會模糊了
@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min--moz-device-pixel-ratio:1.5),only screen and (min-device-pixel-ratio:1.5),only screen and (min-resolution:200dpi) { #logo{background-image: url(logo@2x.png);} }
<link rel=」apple-touch-startup-image」 href=」startup.png」 /> // 設置開始頁面圖片 <link rel=」apple-touch-icon」 href=」iphon_tetris_icon.png」/> // 在設置書籤的時候能夠顯示好看的圖標 <link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css"> // 肖像模式樣式 <link rel="stylesheet" media="all and (orientation:landscape)"href="landscape.css" // 風景模式樣式 //豎屏時使用的樣式 <style media="all and (orientation:portrait)" type="text/css"> #landscape { display: none; } </style> //橫屏時使用的樣式 <style media="all and (orientation:landscape)" type="text/css"> #portrait { display: none; } </style>
http://wo.poco.cn/manson/post/id/268780
identifier // An identifying number, unique to each touch event
屏幕旋轉事件:onorientationchange 添加屏幕旋轉事件偵聽,可隨時發現屏幕旋轉狀態(左旋、右旋仍是沒旋)。例子:
function orientationChange() { switch(window.orientation) { case 0: alert("肖像模式 0,screen-width: " + screen.width + "; screen-height:" + screen.height); break; case -90: alert("左旋 -90,screen-width: " + screen.width + "; screen-height:" + screen.height); break; case 90: alert("右旋 90,screen-width: " + screen.width + "; screen-height:" + screen.height); break; case 180: alert("風景模式 180,screen-width: " + screen.width + "; screen-height:" + screen.height); break; };<br>};
addEventListener('load', function(){ orientationChange(); window.onorientationchange = orientationChange; });
// 隱藏地址欄 & 處理事件的時候 ,防止滾動條出現 addEventListener('load', function(){ setTimeout(function(){ window.scrollTo(0, 1); }, 100); });
// 雙手指滑動事件 addEventListener('load', function(){ window.onmousewheel = twoFingerScroll;}, false // 兼容各瀏覽器,表示在冒泡階段調用事件處理程序 (true 捕獲階段) ); function twoFingerScroll(ev) { var delta =ev.wheelDelta/120; //對 delta 值進行判斷(好比正負) ,然後執行相應操做 return true; };
// 判斷是否爲 iPhone : function isAppleMobile() { return (navigator.platform.indexOf('iPad') != -1); };
var v = localStorage.getItem('n') ? localStorage.getItem('n') : ""; // 若是名稱是 n 的數據存在 ,則將其讀出 ,賦予變量 v 。 localStorage.setItem('n', v); // 寫入名稱爲 n、值爲 v 的數據 localStorage.removeItem('n'); // 刪除名稱爲 n 的數據
若是你關閉自動識別後 ,又但願某些電話號碼可以連接到 iPhone 的撥號功能 ,那麼能夠經過這樣來聲明電話連接 ,
<a href="tel:12345654321">打電話給我</a> <a href="sms:12345654321">發短信</a>
或用於單元格:
要關閉這兩項功能,能夠經過autocapitalize 與autocorrect 這兩個選項:
<input type="text" autocapitalize="off" autocorrect="off" />
①「盒模型」的具體描述性質的包圍盒塊內容,包括邊界,填充等等。
-webkit-border-bottom-left-radius: radius; -webkit-border-top-left-radius: horizontal_radius vertical_radius; -webkit-border-radius: radius; //容器圓角 -webkit-box-sizing: sizing_model; 邊框常量值:border-box/content-box -webkit-box-shadow: hoff voff blur color; //容器陰影(參數分別爲:水平X 方向偏移量;垂直Y 方向偏移量;高斯模糊半徑值;陰影顏色值) -webkit-margin-bottom-collapse: collapse_behavior; 常量值:collapse/discard/separate -webkit-margin-start: width; -webkit-padding-start: width; -webkit-border-image: url(borderimg.gif) 25 25 25 25 round/stretch round/stretch; -webkit-appearance: push-button; //內置的CSS 表現,暫時只支持push-button
②「視覺格式化模型」描述性質,肯定了位置和大小的塊元素。
direction: rtl unicode-bidi: bidi-override; 常量:bidi-override/embed/normal
③「視覺效果」描述屬性,調整的視覺效果塊內容,包括溢出行爲,調整行爲,能見度,動畫,變換,和過渡。
clip: rect(10px, 5px, 10px, 5px) resize: auto; 常量:auto/both/horizontal/none/vertical visibility: visible; 常量: collapse/hidden/visible -webkit-transition: opacity 1s linear; 動畫效果 ease/linear/ease-in/ease-out/ease-in-out -webkit-backface-visibility: visibler; 常量:visible(默認值)/hidden -webkit-box-reflect: right 1px; 鏡向反轉 -webkit-box-reflect: below 4px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0.5, transparent), to(white)); -webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,1)), to(rgba(0,0,0,0)));; //CSS 遮罩/蒙板效果 -webkit-mask-attachment: fixed; 常量:fixed/scroll -webkit-perspective: value; 常量:none(默認) -webkit-perspective-origin: left top; -webkit-transform: rotate(5deg); -webkit-transform-style: preserve-3d; 常量:flat/preserve-3d; (2D 與3D)
④「生成的內容,自動編號,並列出」描述屬性,容許您更改內容的一個組成部分,建立自動編號的章節和標題,和操縱的風格清單的內容。
content: 「Item」 counter(section) 」 「; This resets the counter. First section >two section three section counter-increment: section 1; counter-reset: section;
⑤「分頁媒體」描述性能與外觀的屬性,控制印刷版本的網頁,如分頁符的行爲。
page-break-after: auto; 常量:always/auto/avoid/left/right page-break-before: auto; 常量:always/auto/avoid/left/right page-break-inside: auto; 常量:auto/avoid
⑥「顏色和背景」描述屬性控制背景下的塊級元素和顏色的文本內容的組成部分。
-webkit-background-clip: content; 常量:border/content/padding/text -webkit-background-origin: padding; 常量:border/content/padding/text -webkit-background-size: 55px; 常量:length/length_x/length_y
⑦ 「字型」的具體描述性質的文字字體的選擇範圍內的一個因素。報告還描述屬性用於下載字體定義。
unicode-range: U+00-FF, U+980-9FF;
⑧「文本」描述屬性的特定文字樣式,間距和自動滾屏。
text-shadow: #00FFFC 10px 10px 5px; text-transform: capitalize; 常量:capitalize/lowercase/none/uppercase word-wrap: break-word; 常量:break-word/normal -webkit-marquee: right large infinite normal 10s; 常量:direction(方向) increment(迭代次數) repetition(重複) style(樣式) speed(速度); -webkit-marquee-direction: ahead/auto/backwards/down/forwards/left/reverse/right/up -webkit-marquee-incrementt: 1-n/infinite(無窮次) -webkit-marquee-speed: fast/normal/slow -webkit-marquee-style: alternate/none/scroll/slide -webkit-text-fill-color: #ff6600; 常量:capitalize, lowercase, none, uppercase -webkit-text-security: circle; 常量:circle/disc/none/square -webkit-text-size-adjust: none; 常量:auto/none; -webkit-text-stroke: 15px #fff; -webkit-line-break: after-white-space; 常量:normal/after-white-space -webkit-appearance: caps-lock-indicator; -webkit-nbsp-mode: space; 常量: normal/space -webkit-rtl-ordering: logical; 常量:visual/logical -webkit-user-drag: element; 常量:element/auto/none -webkit-user-modify: read- only; 常量:read-write-plaintext-only/read-write/read-only -webkit-user-select: text; 常量:text/auto/none
⑨「表格」描述的佈局和設計性能表的具體內容。
-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; -webkit-column-break-after: right; 常量:always/auto/avoid/left/right -webkit-column-break-before: right; 常量:always/auto/avoid/left/right –webkit-column-break-inside: logical; 常量:avoid/auto -webkit-column-count: 3; //分欄 -webkit-column-rule: 1px solid #fff; style:dashed,dotted,double,groove,hidden,inset,none,outset,ridge,solid
⑩「用戶界面」描述屬性,涉及到用戶界面元素在瀏覽器中,如滾動文字區,滾動條,等等。報告還描述屬性,範圍之外的網頁內容,如光標的標註樣式和顯示當您按住觸摸觸摸 目標,如在iPhone上的連接。
-webkit-box-align: baseline,center,end,start,stretch 常量:baseline/center/end/start/stretch -webkit-box-direction: normal;常量:normal/reverse -webkit-box-flex: flex_valuet -webkit-box-flex-group: group_number -webkit-box-lines: multiple; 常量:multiple/single -webkit-box-ordinal-group: group_number -webkit-box-orient: block-axis; 常量:block-axis/horizontal/inline-axis/vertical/orientation –webkit-box-pack: alignment; 常量:center/end/justify/start
動畫過渡 這是 Webkit 中最具創新力的特性:使用過渡函數定義動畫。
-webkit-animation: title infinite ease-in-out 3s; animation 有這幾個屬性: -webkit-animation-name: //屬性名,就是咱們定義的keyframes -webkit-animation-duration:3s //持續時間 -webkit-animation-timing-function: //過渡類型:ease/ linear(線性) /ease-in(慢到快)/ease-out(快到慢) /ease-in-out(慢到快再到慢) /cubic-bezier -webkit-animation-delay:10ms //動畫延遲(默認0) -webkit-animation-iteration-count: //循環次數(默認1),infinite 爲無限 -webkit-animation-direction: //動畫方式:normal(默認 正向播放); alternate(交替方向,第偶數次正向播放,第奇數次反向播放)
這些一樣是能夠簡寫的。但真正讓我覺的很爽的是keyframes,它能定義一個動畫的轉變過程供調用,過程爲0%到100%或from(0%)到to(100%)。簡單點說,只要你有想法,你想讓元素在這個過程當中以什麼樣的方式改變都是很簡單的。
-webkit-transform: 類型(縮放scale/旋轉rotate/傾斜skew/位移translate) scale(num,num) 放大倍率。scaleX 和 scaleY(3),能夠簡寫爲:scale(* , *) rotate(*deg) 轉動角度。rotateX 和 rotateY,能夠簡寫爲:rotate(* , *) Skew(*deg) 傾斜角度。skewX 和skewY,可簡寫爲:skew(* , *) translate(*,*) 座標移動。translateX 和translateY,可簡寫爲:translate(* , *)。
media query相信大部分人已經使用過了。其實javascript能夠配合media query這麼用:
var mql = window.matchMedia("(orientation: portrait)"); mql.addListener(handleOrientationChange); handleOrientationChange(mql); function handleOrientationChange(mql) { if (mql.matches) { alert('The device is currently in portrait orientation ') } else { alert('The device is currently in landscape orientation') }}
我我的理解,是藉助了media query接口作的事件監聽,因此很強大!
ontouchmove="event.preventDefault()" //鎖定viewport,任何屏幕操做不移動用戶界面(彈出鍵盤除外)。
-webkit-tap-highlight-color: 顏色
開發特定設備的移動網站,首先要作的就是設備偵測了。下面是使用Javascript偵測iPhone/iPod的UA,而後轉向到專屬的URL。
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("iphone_redirect=false") == -1) { window.location = "http://m.example.com"; } }
雖然Javascript是能夠在水果設備上運行的,可是用戶仍是能夠禁用。它也會形成客戶端刷新和額外的數據傳輸,因此下面是服務器端偵測和轉向:
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) { header('Location: http://yoursite.com/iphone'); exit(); }
html, body, form, fieldset, p, div, h1, h2, h3, h4, h5, h6 {-webkit-text-size-adjust:none;}
若是不想設備偵測,能夠用CSS媒體查詢來專爲iPhone/iPod定義樣式。
@media screen and (max-device-width: 480px) {}
網站的大圖一般寬度都超過480像素,若是用前面的代碼限制了縮放,這些圖片在iPhone版顯示顯然會超過屏幕。好在iPhone機能還夠,咱們能夠用CSS讓iPhone自動將大圖片縮小顯示。
@media screen and (max-device-width: 480px){ img{max-width:100%;height:auto;} }
由於iPhone並無鼠標指針,因此沒有hover事件。那麼CSS :hover僞類就沒用了。可是iPhone有Touch事件,onTouchStart 相似 onMouseOver,onTouchEnd 相似 onMouseOut。因此咱們能夠用它來模擬hover。使用Javascript:
var myLinks = document.getElementsByTagName('a'); for(var i = 0; i < myLinks.length; i++){ myLinks[i].addEventListener(’touchstart’, function(){this.className = 「hover」;}, false); myLinks[i].addEventListener(’touchend’, function(){this.className = 「」;}, false); }
而後用CSS增長hover效果:
a:hover, a.hover { /* 你的hover效果 */ }
這樣設計一個連接,感受能夠更像按鈕。而且,這個模擬能夠用在任何元素上。
##利用高質量圖片優化retina屏幕的顯示(來自大漠)
使用CSS3的background-size優化蘋果的Retina屏幕的圖像顯示
使用css sprites來優化你的網站在Retina屏幕下顯示
http://www.iunbug.com/archives/2013/04/23/798.html
今天發現,要讓a連接的Css active僞類生效,只須要給這個a連接的touch系列的任意事件touchstart/touchend綁定一個空的匿名方法便可hack成功
<style> a { color: #000; } a:active { color: #fff; } </style> <a herf=」asdasd」>asdasd</a> <script> var a=document.getElementsByTagName(‘a’); for(var i=0;i<a.length;i++){ a[i].addEventListener(‘touchstart’,function(){},false); } </script>
兩個方法
-webkit-transform-style: preserve-3d; /*設置內嵌的元素在 3D 空間如何呈現:保留 3D*/ -webkit-backface-visibility:?hidden; /*(設置進行轉換的元素的背面在面對用戶時是否可見:隱藏)*/
http://msdn.microsoft.com/en-us/library/windows/apps/hh767361.aspx
input:-ms-clear{display:none;}
http://blog.sina.com.cn/s/blog_6da647a601011u4v.html http://stackoverflow.com/questions/3220662/uiwebview-font-is-thinner-in-portrait-than-landscape
click 事件廣泛 300ms 的延遲 在手機上綁定click 事件,會使得操做有300ms 的延遲,體驗並非很好。 開發者大多數會使用封裝的 tap 事件來代替click 事件,所謂的 tap 事件由 touchstart 事件 + touchmove 判斷 + touchend 事件封裝組成
https://developers.google.com/mobile/articles/fast_buttons?hl=de-DEhttp://stackoverflow.com/questions/12238587/eliminate-300ms-delay-on-click-events-in-mobile-safari
使用css3動畫的時儘可能利用3D加速,從而使得動畫變得流暢。動畫過程當中的動畫閃白能夠經過backface-visibility 隱藏。
-webkit-transform-style: preserve-3d; -webkit-backface-visibility: hidden;
Iphone 4的一個 CSS 像素實際上表現爲一塊 2×2 的像素。因此圖片像是被放大2倍同樣,模糊不清晰。
解決辦法:
一、頁面引用
<link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio: 0.75)" href="ldpi.css" /> <link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio: 1.0)" href="mdpi.css" /> <link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio: 1.5)" href="hdpi.css" /> <link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio: 2.0)" href="retina.css" />
二、CSS文件裏
#header { background:url(mdpi/bg.png); } @media screen and (-webkit-device-pixel-ratio: 1.5) { /*CSS for high-density screens*/ #header { background:url(hdpi/bg.png); } }
http://www.mansonchor.com/blog/blog_detail_73.html
<meta content="email=no" name="format-detection" />
-webkit-touch-callout:none
-webkit-user-select:none
http://paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/
window.scrollY window.scrollX
好比要綁定一個touchmove的事件,正常的狀況下相似這樣(來自呼吸二氧化碳)
$('div').on('touchmove', function(){ //.….code {});
而若是中間的code須要處理的東西多的話,fps就會降低影響程序順滑度,而若是改爲這樣
$('div').on('touchmove', function(){ setTimeout(function(){ //.….code },0); {});
把代碼放在setTimeout中,會發現程序變快.
能夠經過正則去掉
this.value = this.value.replace(/\u2006/g, '');
Android web視圖,至少在HTC EVO和三星的Galaxy Nexus中,文本輸入框在輸入時表現的就像佔位符。狀況爲一個相似水印的東西在用戶輸入區域,一旦用戶開始輸入便會消失(見圖片)。 在android的默認樣式下當輸入框得到焦點後,若存在一個絕對定位或者fixed的元素,佈局會被破壞,其餘元素與系統輸入字段會發生重疊(如搜索圖標將消失爲搜索字段),能夠觀察到佈局與原始輸入字段有誤差(見截圖)。 這是一個至關複雜的問題,如下簡單佈局能夠重現這個問題:
<label for="phone">Phone: *</label> <input type="tel" name="phone" id="phone" minlength="10" maxlength="10" inputmode="latin digits" required="required" />
解決方法
-webkit-user-modify: read-write-plaintext-only
詳細參考http://www.bielousov.com/2012/android-label-text-appears-in-input-field-as-a-placeholder/ 注意,該屬性會致使中文不能輸入詞組,只能單個字。感謝鬼哥與飛(遊勇飛)貢獻此問題與解決方案
另外,在position:fixed後的元素裏,儘可能不要使用輸入框。更多的bug可參考
依舊沒法解決(摩托羅拉ME863手機),則使用input:text類型而非password類型,並設置其設置 -webkit-text-security: disc; 隱藏輸入密碼從而解決。
解決方法刪除了overflow-x:hidden; 而後在JS生成下來菜單以後focus聚焦,這兩步操做以後解決了問題。(來自島都-小Qi)
input::-webkit-input-speech-button {display: none}
【UC瀏覽器】video標籤脫離文檔流
場景:標籤的父元素(祖輩元素)設置transform樣式後,標籤會脫離文檔流。
測試環境:UC瀏覽器 8.7/8.6 + Android 2.3/4.0 。
Demo:http://t.cn/zj3xiyu
解決方案:不使用transform屬性。translate用top、margin等屬性替代。
【UC瀏覽器】video標籤總在最前
場景:標籤老是在最前(能夠理解爲video標籤的z-index屬性是Max)。
測試環境:UC瀏覽器 8.7/8.6 + Android 2.3/4.0 。
【UC瀏覽器】position:fixed 屬性在UC瀏覽器的奇葩現象
場景:設置了position: fixed 的元素會遮擋z-index值更高的同輩元素。
在8.6的版本,這個狀況直接出現。
在8.7以後的版本,當同輩元素的height大於713這個「神奇」的數值時,纔會被遮擋。
測試環境:UC瀏覽器 8.8_beta/8.7/8.6 + Android 2.3/4.0 。
Demo:http://t.cn/zYLTSg6
【QQ手機瀏覽器】不支持HttpOnly
場景:帶有HttpOnly屬性的Cookie,在QQ手機瀏覽器版本從4.0開始失效。JavaScript能夠直接讀取設置了HttpOnly的Cookie值。
測試環境:QQ手機瀏覽器 4.0/4.1/4.2 + Android 4.0 。
【MIUI原生瀏覽器】瀏覽器地址欄hash不改變
場景:location.hash 被賦值後,地址欄的地址不會改變。
但實際上 location.href 已經更新了,經過JavaScript能夠順利獲取到更新後的地址。
雖然不影響正常訪問,但用戶沒法將訪問過程當中改變hash後的地址存爲書籤。
測試環境:MIUI 4.0
【Chrome Mobile】fixed元素沒法點擊
場景:父元素設置position: fixed;
子元素設置position: absolute;
此時,若是父元素/子元素還設置了overflow: hidden 則出現「父元素遮擋該子元素「的bug。
視覺(view)層並無出現遮擋,只是沒法觸發綁定在該子元素上的事件。可理解爲:「看到點不到」。
補充: 頁面往下滾動,觸發position: fixed;的特性時,纔會出現這個bug,在最頂不會出現。
測試平臺: 小米1S,Android4.0的Chrome18
demo: http://maplejan.sinaapp.com/demo/fixed_chromemobile.html
解決辦法: 把父元素和子元素的overflow: hidden去掉。
以上來源於 http://www.cnblogs.com/maplejan/archive/2013/04/26/3045928.html
iscroll4的幾個bug(來自http://www.mansonchor.com/blog/blog_detail_64.html內有詳細講解)
1.滾動容器點擊input框、select等表單元素時沒有響應】
onBeforeScrollStart: function (e) { e.preventDefault(); }
改成
onBeforeScrollStart: function (e) { var nodeType = e.explicitOriginalTarget © e.explicitOriginalTarget.nodeName.toLowerCase():(e.target © e.target.nodeName.toLowerCase():'');if(nodeType !='select'&& nodeType !='option'&& nodeType !='input'&& nodeType!='textarea') e.preventDefault(); }
2.往iscroll容器內添加內容時,容器閃動的bug
源代碼的
has3d = 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix()
改爲
has3d = false
在配置iscroll時,useTransition設置成false
3.過長的滾動內容,致使卡頓和app直接閃退
1)不要使用checkDOMChanges。雖然checkDOMChanges很方便,定時檢測容器長度是否變化來refresh,但這也意味着你要消耗一個Interval的內存空間 2)隱藏iscroll滾動條,配置時設置hScrollbar和vScrollbar爲false。 3)不得已的狀況下,去掉各類效果,momentum、useTransform、useTransition都設置爲false
4.左右滾動時,不能正確響應正文上下拉動
iscroll的閃動問題也與渲染有關係,能夠參考 運用webkit繪製渲染頁面原理解決iscroll4閃動的問題