[問題] 一個文件ready的問題請益

看板Ajax作者 (成為守護神)時間9年前 (2015/12/07 16:35), 9年前編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
現在我正做一個手機版網頁頁面(非app) 問題是我從index.php點連結到content.php?tid=1時 第二頁<head>內的 $(document).ready(function(){ var orgH = $("img").height()/$("img").width() ; var checkOrientation = function(){ mode = Math.abs(window.orientation) == 90 ? 'landscape' : 'portrait'; if ( $.browser.opera ) { width = screen.width; height = screen.height; mode = width > height ? "landscape" : "portrait"; } if (mode == 'landscape') { // 等比縮放闊度 $("img").width("100%"); $("img").height(orgH*$("img").width()) ; } else { $("img").width("100%"); $("img").height(orgH*$("img").width()) ; } }; window.addEventListener("resize", checkOrientation, false); window.addEventListener("orientationchange", checkOrientation, false); setInterval(checkOrientation, 500); }); 的程式碼並沒有從一進這個頁面便執行 必須按重新整理一次,那這樣就沒意義了... 我只是想利用來做出大圖縮到符合手機畫面大小的比例的圖 請問我該如何讓他一次到位? (不可能叫閱讀者每轉一次頁面都按重新整理來讓圖縮成符合size) 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 182.239.101.204 ※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1449477348.A.A0D.html ※ 編輯: mydoc (182.239.101.204), 12/07/2015 16:40:42

12/07 18:28, , 1F
包在resize裡,但是現在都用css3比較多
12/07 18:28, 1F
文章代碼(AID): #1MPKJaeD (Ajax)
文章代碼(AID): #1MPKJaeD (Ajax)