[問題] 一個文件ready的問題請益
現在我正做一個手機版網頁頁面(非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
12/07 18:28, 1F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章