<STYLE>
   .aFilter {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);}
</STYLE>
<a href="#"><IMG src="D:\web\compile\1.gif" CLASS="aFilter" onclick="alert(event.x+'  '+event.y)"></a>

解决方案 »

  1.   

    <STYLE>
       .aFilter { filter:Alpha(opacity=50);}
    </STYLE>
    <div><IMG style="position:absolute" src="1.gif" CLASS="aFilter" onclick="l.click()"></div>
    <a href="x.htm" onclick="window.location=this.href;alert(this.offsetLeft+'  '+this.offsetTop)" id=l>link</a>
      

  2.   

    楼上的真是高手。不过图片虽然盖在链接上,但链接本身无法点击了,只能通过点击图片去触发。请问onclick中的“window.location=this.href”这句话有什么用?--------------------------------------------------------------------------------我想要实现的功能是这样的,比如有一个现成的网页(随便是哪个网站上的,如sina,sohu等),然后在这个html网页中加入一段JavaScript代码(尽量不修改原来的网页本身),使得在一些链接上显示一些透明的图片,楼上的大侠,这样的功能可以实现吗?
      

  3.   

    click that button will goto achor's href:"x.htm"
      

  4.   

    楼上,a href="x.htm" 本身已经有这个作用了,用不着再在onclick中加入“window.location=this.href”这句话了吧?我说的那个功能能够实现吗?
      

  5.   

    #layer1{ absolute:position...function sample()
    {
    document.write( "<div id='layer1' class='aFilter'>Link</div>" );
    }<body onload="sample()">请问这样做为何没有应有的效果,如果在<body>内放置
    <div id='layer1' class='aFilter'>Link</div>"
    这句话就有效果。
      

  6.   

    <a href="D:\web\compile\1.gif">link1</a><br><br>
    <a href="D:\web\compile\1.gif">link2</a><br><br>
    <a href="D:\web\compile\1.gif">link3</a><br><br>
    <button onclick="show()">show</button>
    <script>
    function show(){
      for(i=0;i<document.links.length;i++){
          var posl=document.links[i].offsetLeft+"px"; 
          var post=document.links[i].offsetTop+"px"; 
          var odiv=document.createElement("DIV");
          odiv.innerHTML="<IMG src='D:\\web\\compile\\1.gif'></IMG>"
          document.body.insertBefore(odiv);
          odiv.style.position="absolute"; 
          odiv.style.left=posl; odiv.style.top=post;
          odiv.style.filter="Alpha(opacity=50)";
          odiv.style.zIndex=-1;
       }
     }
    </script>看看是不是你要的效果:)
      

  7.   

    多谢多谢。不知为什么先定义好了层,再在onload()时使用document.write()写出来为什么不行??
      

  8.   

    <html>
    <head>
    <title></title><style type="text/css">
    <!--
    #layer1 { position: absolute;
    top: 20px; left: 20px;
    z-index: 1;
    height: 50px; width: 50px;
    color: white; background-color: blue; }

    .aFilter {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);}
    -->
    </style><script language="javascript">
    <!--
    function sample()
    {
    document.write( "<div id='layer1' class='aFilter'> This is layer 1 </div>" );

    var ele = document.getElementById( "layer1" );
    ele.style.left = 120;
    ele.style.top = 20;
    ele.style.color = "red";
    }
    -->
    </script></head>
    <body onload="sample()" ><!--
    <div id='layer1' class='aFilter'> This is layer 1 </div>
    -->First Line<br>
    Second Line<br>
    Third Line<br></body>
    </html>看上面的例子,我是说document.write没有效果。
      

  9.   

    再问一下,为什么
    document.links[i].style.left
    会出错?说没有style对象??怎样才能获得这个链接的color和backgroundColor??
      

  10.   

    我测试时,document.write 有效果,但是把原来的页面覆盖了<a href="#" style="left:10px" onclick="alert(document.links[0].style.left)">link</a> 没有错啊,是不是你的 i 值大于 links.length 了;如果各个链接没有特殊设定:下面可以分别获得链接颜色,活动链接颜色,以访问链接颜色
    <a href="#" onclick="alert('links color: '+document.linkColor)">link</a>
    <a href="#" onclick="alert('active links color: '+document.alinkColor)">link</a>
    <a href="#" onclick="alert('visited links color: '+document.vlinkColor)">link</a>
    如果链接有特殊设置,用document.links[i].style.color 和
    document.links[i].style.backgroundColor 应该可以获得其颜色设定
      

  11.   

    谢谢,document.links[0].style是有定义的,
    但document.links[0].style.left和document.links[0].style.top是空值,而document.links[0].offsetLeft和offsetTop是有数值的。确实很奇怪。请问你有信箱和MSN或者QQ吗?我有一些问题想请教。
      

  12.   

    document.links[0].style.left  和document.links[0].style.top 没有默认值,要定义后才有值,而document.links[0].offsetLeft和offsetTop是object相对于document的相对位置,在生成object的同时就有了初始值。[email protected]
    qq: 54712524
      

  13.   

    用 window.scrollTo(x,y) 应该可以实现吧。
    建议你学点关于这方面的东西有问题发邮件给我好了,最近比较忙:)
      

  14.   

    OK,我发mail给你,谢谢你的热心回复,结贴。