作者mydoc (成为守护神)
看板Ajax
标题[问题] 一个文件ready的问题请益
时间Mon Dec 7 16:35:44 2015
现在我正做一个手机版网页页面(非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://webptt.com/cn.aspx?n=bbs/Ajax/M.1449477348.A.A0D.html
※ 编辑: mydoc (182.239.101.204), 12/07/2015 16:40:42
1F:推 jhunkyoiori: 包在resize里,但是现在都用css3比较多 12/07 18:28