transmat
07-16-2003, 03:42 PM
I've been unable to retrieve clip info with the code below (in Netscape 7.1 for OS X)
I'm getting an "undefined" warning.
It looks to me that it is defined in the object constructor.
If I just alert this.style, I get "[object CSSStyleDeclaration]". But when I try to ask for properties I get a blank warning or the undefined one.
anyone have experience?
here's the code:
<html>
<head><title></title>
<style>
.box {
background-color: #e4e4e4
}
</style>
<script>
//
WhereIsClipInfo.repository = new Array()
function WhereIsClipInfo(id,left,top,width,height) {
this.dom = document.getElementById ? 1 : 0
if (this.dom) {
this.id = id
this.left = left
this.top = top
this.width = width
this.height = height
this.gObject = "global_"+id
eval(this.gObject + "= this")
var objStyle = '<style type="text\/css">';
objStyle += '#' + this.id + 'Div { position:absolute; '
objStyle += 'left:' + left + 'px; '
objStyle += 'top:' + top + 'px; '
objStyle += 'width:' + width + 'px; '
objStyle += 'height:' + height + 'px; '
objStyle += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
objStyle += '}'
objStyle += '<\/style>';
document.write(objStyle)
this.init()
}
}
WhereIsClipInfo.prototype.init = function() {
var theLayer = this.id + "Div"
var lyr = document.getElementById(theLayer)
if (!lyr) window.setTimeout(this.gObject + ".init()", 100)
else {
this.the_layer = lyr
this.style = this.the_layer.style
alert(this.style.clip.bottom)
}
}
new WhereIsClipInfo("box1",50,50,100,100)
</script>
</head>
<body>
<div id="box1Div" class="box">
this is box 1!
</div>
</body>
</html>
I'm getting an "undefined" warning.
It looks to me that it is defined in the object constructor.
If I just alert this.style, I get "[object CSSStyleDeclaration]". But when I try to ask for properties I get a blank warning or the undefined one.
anyone have experience?
here's the code:
<html>
<head><title></title>
<style>
.box {
background-color: #e4e4e4
}
</style>
<script>
//
WhereIsClipInfo.repository = new Array()
function WhereIsClipInfo(id,left,top,width,height) {
this.dom = document.getElementById ? 1 : 0
if (this.dom) {
this.id = id
this.left = left
this.top = top
this.width = width
this.height = height
this.gObject = "global_"+id
eval(this.gObject + "= this")
var objStyle = '<style type="text\/css">';
objStyle += '#' + this.id + 'Div { position:absolute; '
objStyle += 'left:' + left + 'px; '
objStyle += 'top:' + top + 'px; '
objStyle += 'width:' + width + 'px; '
objStyle += 'height:' + height + 'px; '
objStyle += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
objStyle += '}'
objStyle += '<\/style>';
document.write(objStyle)
this.init()
}
}
WhereIsClipInfo.prototype.init = function() {
var theLayer = this.id + "Div"
var lyr = document.getElementById(theLayer)
if (!lyr) window.setTimeout(this.gObject + ".init()", 100)
else {
this.the_layer = lyr
this.style = this.the_layer.style
alert(this.style.clip.bottom)
}
}
new WhereIsClipInfo("box1",50,50,100,100)
</script>
</head>
<body>
<div id="box1Div" class="box">
this is box 1!
</div>
</body>
</html>