Javascript jQuery移动定位图像
大家好,我有一个问题 我在设备上的jQuery移动代码有一个奇怪的问题 iPad2示例:Javascript jQuery移动定位图像,javascript,html,css,jquery-mobile,Javascript,Html,Css,Jquery Mobile,大家好,我有一个问题 我在设备上的jQuery移动代码有一个奇怪的问题 iPad2示例: 因此,当我以纵向模式在手机中启动页面时,图像看起来是这样的(不应该像这样缩小) 当我打开横向模式时,它仍然可以正常工作 当我再次在肖像模式下改变它时,恐怖发生了 在此之后,它仅在模式2和3之间变化 我在LG OptimusG上试用过,它在simmillar上运行,只是在模式1上,它不像iPad那样缩小了 我在没有JQM的单独页面中尝试了这一点,当插入JQM时,问题就开始了 我使用了ImageMapst
我希望你能理解这个问题。。。
我还有其他问题要问
希望你能帮我解决这个问题。。。谢谢
更新:
内部HTML:
<div role="content" class="ui-content">
<img src="images/map.jpg"
usemap="#usa" style="width:100%;">
<map id="usa_image_map" name="usa">
<area href="http://www.google.com" state="NH" full="New Hampshire" onclick="haha();" shape="poly" coords="251,99,376,138,477,180,601,279,644,319,593,369,512,332,535,291,527,282,524,281,499,329,387,281,382,289,316,269,323,254,280,235,285,220,254,206,249,219,234,212,192,74,248,74,236,98">
<area href="http://www.google.com" state="NH" full="New Hampshire" onclick="haha2();" shape="poly" coords="109,205,136,302,191,287,184,262,212,254,210,246">
<area href="http://www.google.com" state="NH" full="New Hampshire" onclick="haha3();" shape="poly" coords="67,45,98,158,199,200,155,68,104,68,101,47">
</map>
</div>
脚本如下所示:
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
var resizeTime = 100; // total duration of the resize effect, 0 is instant
var resizeDelay = 100; // time to wait before checking the window size again
// the shorter the time, the more reactive it will be.
// short or 0 times could cause problems with old browsers.
$('img').mapster({
mapKey: 'state'
});
// Resize the map to fit within the boundaries provided
function resize(maxWidth,maxHeight) {
var image = $('img'),
imgWidth = image.width(),
imgHeight = image.height(),
newWidth=0,
newHeight=0;
if (imgWidth/maxWidth>imgHeight/maxHeight) {
newWidth = maxWidth;
} else {
newHeight = maxHeight;
}
image.mapster('resize',newWidth,newHeight,resizeTime);
}
function onWindowResize() {
var curWidth = $(window).width(),
curHeight = $(window).height(),
checking=false;
if (checking) {
return;
}
checking = true;
window.setTimeout(function() {
var newWidth = $(window).width(),
newHeight = $(window).height();
if (newWidth === curWidth &&
newHeight === curHeight) {
resize(newWidth,newHeight);
}
checking=false;
},resizeDelay );
}
$(window).bind('resize',onWindowResize);
});//]]>
function haha(){
window.location.href = "glavna.html#pageprostori";
};
function haha2(){
window.location.href = "glavna.html#pageopis";
};
function haha3(){
window.location.href = "glavna.html#pagekontakt";
};
</script>
//imgHeight/maxHeight){
newWidth=maxWidth;
}否则{
newHeight=maxHeight;
}
mapster('resize',newWidth,newHeight,resizeTime);
}
函数onWindowResize(){
var curWidth=$(窗口).width(),
curHeight=$(窗口).height(),
检查=假;
如果(检查){
返回;
}
检查=真;
setTimeout(函数(){
var newWidth=$(窗口).width(),
newHeight=$(window.height();
如果(newWidth==curWidth&&
newHeight==curHeight){
调整大小(新宽度、新高度);
}
检查=假;
},重定尺寸延迟);
}
$(窗口).bind('resize',onWindowResize);
});//]]>
函数haha(){
window.location.href=“glavna.html#pageprosori”;
};
函数haha2(){
window.location.href=“glavna.html#pageopis”;
};
函数haha3(){
window.location.href=“glavna.html#pagekontakt”;
};
我已经把它包含在html头中了
<script type='text/javascript' src="http://www.outsharked.com/scripts/jquery.imagemapster.js"></script>
是否将标记包装在content
div中<代码>
如果您使用的是jqm 1.4是的,我是。。。我试着把它放在content div内,在footer div外。。。。没有成功…您是否尝试过在orientationchange
事件中重新加载地图?我不知道这是否是问题所在,因为即使在启动时图像也“损坏”。。。。我会尝试,但我怀疑方向改变能解决这个问题,你们什么时候渲染地图?调用函数?
<script type='text/javascript' src="http://www.outsharked.com/scripts/jquery.imagemapster.js"></script>