Javascript不能只在firefox中工作
Javascript doesn't work in only firefox
我有一个脚本悬停在缩略图上,它将显示一个放大的图像。这在IE, Chrome和Safari中工作得很好。但是在Firefox中却不能正常工作。它将显示图像,但它不会正确地悬停在图像旁边。它将停留在页面上的绝对位置,而不跟随真正的body值。它应该在一个固定的位置,就像它是在IE或chrome。
我想知道是否有一个Mozilla或Firefox特定的例外,我需要添加。
// Simple Image Trail script- By JavaScriptKit.com
var offsetfrommouse = [15, 10]; //image x,y offsets from cursor position in pixels.
var myimageheight = 250;
var myimagewidth = 250;
if (document.getElementById || document.all) {
document.write('<div id="DynPreviewPlace"></div>');
}
function gettrailobj() {
if (document.getElementById)
return document.getElementById("DynPreviewPlace").style
else if (document.all)
return document.all.DynPreviewPlace.style
}
function gettrailobjnostyle() {
if (document.getElementById)
return document.getElementById("DynPreviewPlace")
else if (document.all)
return document.all.DynPreviewPlace
}
function truebody() {
if (window.getComputedStyle && !window.globalStorage && !window.opera) {
return (!window.chrome && window.getComputedStyle && document.compatMode != "CSS1Compat") ? document.documentElement : document.body
} else if () {} else {
return (!window.chrome && document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}
}
function showtrail(imagename, title, width, height) {
document.onmousemove = followmouse;
(height == 0) ? height = myimageheight : '';
width += 15
height += 30
myimageheight = height
myimagewidth = width
newHTML = '<div class="DynPreviewWraper" style="width:' + width + 'px;"><div id="DynPreviewContainer"><div class="DynPreviewLoader"><div align="center">Loading preview...</div><div class="DynPreviewLoaderBg"><div id="DynProgress"> </div></div></div></div>';
newHTML = newHTML + '<h2 class="DynPreviewTitle">' + ' ' + title + '</h2>'
newHTML = newHTML + '<img onload="javascript:remove_loading();" src="' + imagename + '" class="DynPreviewTempLoad" alt="" />';
newHTML = newHTML + '<!--[if lte IE 6.5]><iframe></iframe><![endif]--></div>';
gettrailobjnostyle().innerHTML = newHTML;
gettrailobj().display = "block";
}
function hidetrail() {
gettrailobj().innerHTML = " ";
gettrailobj().display = "none"
document.onmousemove = ""
gettrailobj().left = "-500px"
}
function followmouse(e) {
var xcoord = offsetfrommouse[0]
var ycoord = offsetfrommouse[1]
var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15
var docheight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
if (typeof e != "undefined") {
if (docwidth - e.pageX < myimagewidth + 2 * offsetfrommouse[0]) {
xcoord = e.pageX - xcoord - myimagewidth;
} else {
xcoord += e.pageX;
}
if (docheight - e.pageY < (myimageheight + 110)) {
ycoord += e.pageY - Math.max(0, (110 + myimageheight + e.pageY - docheight - truebody().scrollTop));
} else {
ycoord += e.pageY;
}
} else if (typeof window.event != "undefined") {
if (docwidth - event.clientX < myimagewidth + 2 * offsetfrommouse[0]) {
xcoord = event.clientX + truebody().scrollLeft - xcoord - myimagewidth;
} else {
xcoord += truebody().scrollLeft + event.clientX
}
if (docheight - event.clientY < (myimageheight + 110)) {
ycoord += event.clientY + truebody().scrollTop - Math.max(0, (110 + myimageheight + event.clientY - docheight));
} else {
ycoord += truebody().scrollTop + event.clientY;
}
}
var docwidth = document.all ? truebody().scrollLeft + truebody().clientWidth : pageXOffset + window.innerWidth - 15
var docheight = document.all ? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
if (ycoord < 0) {
ycoord = ycoord * -1;
}
gettrailobj().left = xcoord + 'px';
gettrailobj().top = ycoord + 'px';
}
var t_id = setInterval(animate, 20);
var pos = 0;
var dir = 2;
var len = 0;
function animate() {
var elem = document.getElementById('DynProgress');
if (elem != null) {
if (pos == 0) len += dir;
if (len > 32 || pos > 79) pos += dir;
if (pos > 79) len -= dir;
if (pos > 79 && len == 0) pos = 0;
}
}
function remove_loading() {
this.clearInterval(t_id);
var targelem = document.getElementById('DynPreviewContainer');
targelem.style.display = 'none';
targelem.style.visibility = 'hidden';
var t_id = setInterval(animate, 60);
}
这快把我逼疯了。我什么都试过了。您可以在这里看到问题所在的页面:https://www.woodenduckshoppe.com/shoppe/christmas-decorations/
你的真实体函数在不同的代码中运行吃嫩叶的动物你试过不那么做吗?- Boris Zbarsky 15 hours ago
我一直在想在那里写些什么。我只是不知道firefox/mozilla该放什么。这是唯一一个有问题的浏览器。
我看到Firefox无法读取真实体,我只是不知道为什么或如何修复它
相关文章:
- 为什么这在IE中的工作方式与在Firefox中不同
- JS可以在Chrome中工作,但不能在Firefox中工作
- Facebook登录按钮没有'不能在Firefox上工作
- JS在firefox中无法正常工作
- firefox插件:退出不工作的应用程序观察器
- :focus:一起活跃,不在firefox上工作
- 加载Soundcloud嵌入式播放器OnClick在FireFox中不工作
- javascript()onclick隐藏元素-dos'我不在firefox工作
- 异步加载的SVG过滤器feColorMatrix在Chrome中工作,而不是在Safari或Firefox中
- Iframe加载调整大小在Chrome中工作,但不能在IE或Firefox中工作
- 按钮处于活动状态,焦点无法在Mac FireFox上工作
- HTML5 Canvas undo是'在IE或Firefox中无法正常工作
- javascript代码,用于删除firefox中的空白,但在IE和chrome中无法正常工作
- JavaScript 在 Chrome 中工作,而不是在 Firefox 中
- jQuery代码在Firefox中工作,但在IE中失败
- Javascript加载功能只能在一半的时间内工作(Firefox)
- jQuery点击不工作FireFox -可能是event.preventdefault
- JQUERY .load不能与窗口一起工作.firefox中的位置
- Javascript菜单不工作Firefox
- Jquery只在我重新加载页面时工作-Firefox