1) I am trying to place a transparent image over an embedded object. I am missing positions, relative and absolute, somewhere. But where?
I am actually placing the transparent image because I cannot use cursor:pointer
for the object embed. So my idea was to pla开发者_如何转开发ce a transparent image and use cursor:pointer
.
2) Why doesn't onclick
work in IE? It works fine in Firefox and 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>
Thanks in advance!
With your given code, add the position values to position: relative
on #divmarquee
, and change position to position: absolute
and add cursor: pointer
on #imgtrans
:
#divmarquee { position: relative; }
#imgtrans { position: absolute; cursor: pointer; }
See here: http://jsfiddle.net/blineberry/pJZ2t/
In your code above you added cursor: pointer to the embed-tag. Try moving it to the image tag instead.
Don't use an <img>
, use a <div>
and make sure it expands to the width and height of the object.
Apply the cursor: pointer style to divmarquee.
For your onclick problem try these:
first, try
onclick = function(){window.location='http://www.google.com';return false;}
then try to change it to this:
onclick = window.location.href='somesite'
you can also try:
onclick = document.location='somesite'
if that doesn't work try:
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
ONE OF THOSE WILL WORK
<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>
cursor: pointer
will work when you wrap the object in a html hyperlink.
精彩评论