C# 如何获取嵌入对象上的游标:指针?
1) 我试图在嵌入的对象上放置一个透明图像。我在某处丢失了位置,相对的和绝对的。但是在哪里呢 我实际上是在放置透明图像,因为我无法对嵌入的对象使用C# 如何获取嵌入对象上的游标:指针?,c#,asp.net,html,css,C#,Asp.net,Html,Css,1) 我试图在嵌入的对象上放置一个透明图像。我在某处丢失了位置,相对的和绝对的。但是在哪里呢 我实际上是在放置透明图像,因为我无法对嵌入的对象使用cursor:pointer。所以我的想法是放置一个透明的图像并使用光标:指针 2) 为什么onclick不能在IE中工作?它在Firefox和Chrome中运行良好 <div id="divmarquee" runat="server" > <img id="imgtrans" runat="server" src= "/
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>
提前谢谢 光标:指针将在html超链接中包装对象时起作用。在上面的代码中添加光标:指向嵌入标记的指针。尝试将其移动到图像标记。不要使用
,使用
,并确保其扩展到对象的宽度和高度。使用给定的代码,将位置值添加到上的位置:相对,并将位置更改为位置:绝对
,并在#imgtrans
上添加光标:指针
:
#divmarquee { position: relative; }
#imgtrans { position: absolute; cursor: pointer; }
请参见此处:将光标:指针样式应用于divmarquee。对于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
其中一个会起作用
<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>
一个更尖锐的问题是“如何获取光标:嵌入对象上的指针”,我确实尝试过,但没有成功:(您知道的其他方法吗?您是否尝试过删除z-index并使用标记,因为z-index总是有问题如果您为锚定设置了href,这将起作用。最好防止onclick处理程序中的default/return false,以确保链接不会尝试导航。)