firefox下JS不好使,在IE上好用.关于缩略图的问题.大侠帮帮忙啊

莳心 2008-11-10 01:40:10
在FIREFOX下这个属性好像得不到值,是不是FIREFOX下不能这样用啊..怎么改啊.先谢谢大家了.
layer.style.left =l + 35 -90;
layer.style.top = t+35-90;
下面的代码在IE中没有问题,在FIERFOX下显示就跑到了边上.位置和IE中的不一样.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<script language="JavaScript" type="text/JavaScript" >
function hideLayer()
{
var layer = document.getElementById("popImageLayer");
layer.style.visibility='hidden';
}
function dispear(){
var layer = document.getElementById("popImageLayer");
if ((layer.style.width>0)&& (layer.style.height>0)){
layer.style.width-=1;
layer.style.height-=1;
}
else {
layer.style.visibility='hidden';
if (window.interval)
clearInterval(interval);
}
}
function popImage(obj,img,href)
{
var layer = document.getElementById("popImageLayer");
var t=obj.offsetTop;
var l=obj.offsetLeft;
while(obj=obj.offsetParent){
t+=obj.offsetTop;
l+=obj.offsetLeft;
}
var content = "<table border=0 width=180 height=180><tr><td align='center' valign='middle'>\n"+
"<A href="+href+" target=_blank><IMG src='"+img+"' onload='DrawImage(this,180,180);' onMouseOut='low(this);hideLayer();' onMouseOver=high(this) style='FILTER: alpha(opacity=10)'></A></td></tr></table>"; // onClick='hideLayer();'
layer.innerHTML=content;
layer.style.left =l + 35 -90;
layer.style.top = t+35-90;
layer.style.visibility='visible';
}
function moveToMouseLoc(e)
{
var layer = document.getElementById("popImageLayer");
var offsetX = -5;
var offsetY = -5;
var x = event.x + document.body.scrollLeft;
var y = event.y + document.body.scrollTop;
layer.style.left = x + offsetX;
layer.style.top = y + offsetY;
return true;
}
function DrawImage(img,width,height){
if(DrawImage.arguments.length <= 1)
width=height=70;
var image=new Image();
image.src=img.src;
if(image.width>0 && image.height>0)
{
if(image.width>width)
{
rate=image.height/image.width;
newHeight=rate*width;
img.width=width;
img.height=newHeight;
}
}
if(img.height>height)
{
rate=image.width/image.height;
newWidth=rate*height;
img.height=height;
img.width=newWidth;
}
}
function DrawImage50(img){
DrawImage(img,50,50);
}
function resetForm(){
var f=document.frmsearch;
f.Page.value = 1;
f.ClassCode.value ='' ;
f.SortType.value ='' ;
f.KeyWord.value='';
f.Area.value='';
f.MinPrice.value=f.MaxPrice.value='';
return false;
}
function manualSearch(){
var f=document.frmsearch;
f.Page.value = 1;
// f.ClassCode.value ='' ;
f.SortType.value ='' ;
f.submit();
return false;
}
function checkCondition(obj) {
return true;
}
function selectview(obj)
{
var f=document.frmsearch;
if ((obj.selectedIndex>0) && (obj.selectedIndex <7))
f.SortType.value = obj.options[obj.selectedIndex].value;
else if ((obj.selectedIndex>6) && (obj.selectedIndex <10))
f.View.value = obj.options[obj.selectedIndex].value;
else if ((obj.selectedIndex>9) && (obj.selectedIndex <13))
f.PageSize.value = obj.options[obj.selectedIndex].value;
f.submit();
return false;
}
function changeLocation(obj){
var f=document.frmsearch;
f.Area.value = obj.options[obj.selectedIndex].value;
f.submit();
return false;
}
function changeViewMode(mode){
var f=document.frmsearch;
f.View.value = mode;
f.submit();
return false;
}
function changePage(page){
var f=document.frmsearch;
f.Page.value = page;
f.submit();
return false;
}
function changePageSize(pagesize){
var f=document.frmsearch;
f.Page.value = 1;
f.PageSize.value = pagesize;
f.submit();
return false;
}
function changeSortType(type){
var f=document.frmsearch;
f.Page.value = 1;
f.SortType.value = type;
f.submit();
return false;
}
function changeClassCode(code){
var f=document.frmsearch;
f.ClassCode.value = code;
f.Page.value=1;
f.submit();
return false;
}
function high(which2){
theobject=which2;
highlighting=setInterval("highlightit(theobject)",40);
}
function low(which2){
clearInterval(highlighting);
which2.filters.alpha.opacity=40;
}
function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=5
else if (window.highlighting)
clearInterval(highlighting)
}
function delightit(cur2){
if (cur2.filters.alpha.opacity>5)
cur2.filters.alpha.opacity-=5;
else if (window.highlighting)
clearInterval(highlighting);
}
</script>
<div id="popImageLayer" align="center" name="popImageLayer" style="position:absolute; visibility: hidden; width: 180; height: 180;cursor: hand;border-style:solid;border-width:1pt; border-color:orange" calss=""></div>
<center>
<br /><br /><br />
<div id="090" ><img src="http://admin.mall.dangdang.com/GoodsImage/S000000460/Small/200608090909231.png" onMouseOver="popImage(this,'http://admin.mall.dangdang.com/GoodsImage/S000000460/Middle/200608090909231.png','http://wangfenglitai.mall.dangdang.com/products/G00000072867.html');" border=0>hkjhgkhk</div></a>
</center>
</body>
</html>


...全文
152 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
sgdb 2008-11-10
  • 打赏
  • 举报
回复
FF 需要这样使用

layer.style.left =l + 35 -90 +'px';
layer.style.top = t+35-90 +'px';
misubaby 2008-11-10
  • 打赏
  • 举报
回复
CSDN论坛改版了?好像好久了,很少看这个东西

FF中给样式指定宽高等值,需要加上单位符

如下:
left = 1 + "px"
libolibo888 2008-11-10
  • 打赏
  • 举报
回复
我这样处理的就好用了。你也试试
libolibo888 2008-11-10
  • 打赏
  • 举报
回复
在工具-》选项-》内容-》启用javascript
管理中-》将baidu/google移去。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧