我有一个包含在 iFrame 中的页面(其中嵌入了一个外部 html 页面)这个页面有一个表单,当鼠标悬停在表单提交按钮上时,它会在提交前计算表单的隐藏值。
我还使用 smoothzoom 库的形式 (http://codecanyon.net/item/smooth-zoom-pan-jquery-image-viewer/full_screen_preview/511142)。
计算示例是根据裁剪 View 的左侧偏移量计算图像的左侧偏移量。
我检查了 chrome 和 firefox 中的元素。
当鼠标悬停在 firefox 中时,所有隐藏字段都会更新。
在 chrome 中只有两个更新。 X 和 Y。
这是我正在使用的 jQuery。
var hovered = false;
$(function(){
$('#image').smoothZoom({
width: 270,
height: 270,
zoom_MAX: 600,
animation_SPEED: 0.001,
animation_SMOOTHNESS: 0,
initial_ZOOM: '100',
initial_POSITION: '0 0'
});
$('#headerImageCont').hover(function(){
hovered = true;
},function(){
hovered = false;
});
$(window).bind("mousewheel", function(event, delta){
if (hovered === true){
return false;
}
});
$('#saveButton').mouseover(function(){
$('#x').val(-$('#image').position().left); //needs to be inverted
$('#y').val(-$('#image').position().top); //needs to be inverted
$('#ScaleX').val($('#image').width() / 500);
$('#ScaleY').val($('#image').height() / 423);
$('#Scale').val($('#image').width() / 500 * 100);
$('#target_width').val($('#headerImageCont').width());
$('#target_height').val($('#headerImageCont').height());
$('#actual_width').val($('#image').width());
$('#actual_height').val($('#image').height());
});
});
最佳答案
chrome 中的图像在这个特定的浏览器中没有使用宽度和高度。 相反,我将原始宽度和高度乘以比例 X 和 Y。
这可以通过这段代码使用 chrome webkit 值来实现。 http://jsfiddle.net/umZHA/
我希望这对某人有帮助。
谢谢你的帮助马可
关于javascript - jQuery 问题与谷歌浏览器中的表单和鼠标悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7846304/