...

View Full Version : problem with style.clip



Gites
03-13-2005, 11:56 AM
Hi
I have done rollover type banner but it is working only under IE. I'am using flash on layer and i'm showing/hidding part of the banner using style.clip=rec(...). Here is code:


<script type="text/javascript" language="JavaScript1.5"> <!--
function put(X, Y){
document.write('<table border=0 cellpadding=0 cellspacing=0 valign=top width="100%"><tr><td>');
tresc = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="780" height="100" id="belka" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="belka.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="belka.swf" quality="high" bgcolor="#ffffff" width="780" height="100" name="belka" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
document.write('<div id="banner" style="position: absolute; overflow: hidden; left: '+X+'px; top: '+Y+'px"; z-index: 1>'+tresc+'</div>');
document.write('</td></tr></table>');
hide(); }

function hide(){
if(document.getElementById) {
var flash = document.getElementById('banner');
flash.style.clip = 'rect(0,780,25,0)';
}
else if(document.layers) {
document.layers['banner'].clip.left = 0;
document.layers['banner'].clip.top = 0;
document.layers['banner'].clip.right = 780;
document.layers['banner'].clip.bottom = 25;
}
else if(document.all) {
document.all['banner'].style.clip = 'rect(0,780,25,0)'; } }
//--></script>

i'm also using function show() which is similar to hide but with different values in rec(...). I call those functions from flash with getUrl("javascript:hide()");
But it works only under IE, in Firefox i get messages like:


Błąd: uncaught exception: [Exception... "Not enough arguments [nsIDOMHTMLDocument.getElementById]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: file:///E:/Moje%20dokumenty/Aktualne%20projekty/flash/baner_rozwijany/ban2.html#xxx :: pokaz :: line 50" data: no]

vwphillips
03-13-2005, 03:20 PM
in addition to the typos

the div width:& height: must be specified

style width, height, top & left must be in 'px'

why use document.write?

you may see the errors better if HTML




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title></title>
<script type="text/javascript" language="JavaScript1.5"> <!--
var flash;

function put(X, Y){
flash=document.getElementById('banner').style;
flash.left=X+'px';
flash.top=Y+'px';
hide();
}

function hide(){
if(document.getElementById) {
flash.clip='rect(0px,780px,25px,0px)';
}
}

//-->
</script>

</head>

<body onload="put(20,100)" >
<div id="banner" style="position:absolute;overflow:hidden;width:800px;height:500px;left:10px;top:10px;z-index:1" ><img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" width="1500" height="1000"></div>
</body>

</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum