2011-05-16 64 views
7

1)我試圖在嵌入對象上放置一個透明圖像。我在某個地方缺少相對和絕對的職位。但是哪裏?如何獲取遊標:嵌入式對象上的指針?

我實際上是放置透明圖像,因爲我不能使用cursor:pointer來嵌入對象。所以我的想法是放置一個透明的圖像,並使用cursor:pointer

2)爲什麼onclick不能在IE中工作?它在Firefox和Chrome中運行良好。

<div id="divmarquee" runat="server" > 
    <img id="imgtrans" runat="server" src= "/images/480x75-blank-transparent" title="Click Here" style="position:relative" /> 
      <object width="475px" height="75px" onclick="window.location='http://www.google.com'; return false;"> 
       <embed src="merchant_images/The_Marquee_Dealn.swf" type="application/x-shockwave-flash" style="z-index: 0; cursor:pointer" wmode="transparent" width="475px" height="75px"> 
       </embed> 
      </object> 
    </div> 

在此先感謝!

+0

一個更尖銳的問題是「我如何得到光標:指針嵌入對象的」 – 2011-05-16 15:33:06

+0

就像你說的:)謝謝! – Remo 2011-05-16 15:39:53

回答

0

請勿使用<img>,請使用<div>並確保其展開爲對象的寬度和高度。

1

與您給定的代碼,添加位置值position: relative#divmarquee,並改變位置position: absolute並添加cursor: pointer#imgtrans

#divmarquee { position: relative; } 
#imgtrans { position: absolute; cursor: pointer; } 

在這裏看到:http://jsfiddle.net/blineberry/pJZ2t/

0

應用光標:指針樣式去divmarquee。

0

爲了您的onclick問題,請嘗試以下:

第一,儘量

onclick = function(){window.location='http://www.google.com';return false;} 

然後嘗試將它改成這樣:

onclick = window.location.href='somesite' 

你也可以嘗試:

onclick = document.location='somesite' 

如果沒有工作嘗試:

var el = document.getElementById("imgtrans").firstChild; 
if (el.addEventListener){ 
    el.addEventListener(
     'click', 
     function(){ 
       window.location='http://www.google.com'; 
       return false;}, 
     false); //Decent Browsers 
     } 
else if (el.attachEvent){ 
     el.attachEvent(
      'onclick', 
      function(){ 
       window.location='http://www.google.com'; 
       return false; 
      } 
    ); 
}//IE 

其中的一個將工作

0
<div id="divmarquee" runat="server" style="z-index: 1; position:relative; cursor:pointer"> 
<div style="z-index: 0; position:relative"> 
<object width="475px" height="75px" onclick="window.location='http://www.google.com'; return false;"> 
<embed src="merchant_images/The_Marquee_Dealn.swf" type="application/x-shockwave-flash" wmode="transparent" width="475px" height="75px"> 
</embed> 
</object> 
</div> 
</div> 
相關問題