/    Sign up×
Community /Pin to ProfileBookmark

Object expected error in javascript

var slideInUse = new Array();

function Slide(objId, options) {
this.obj = document.getElementById(objId);
this.duration = 1;

docObj = document.getElementById(objId);

[COLOR=”Red”]this.height = parseInt(getComputedStyle(docObj, “”).getPropertyValue(“height”)); [/COLOR]

[COLOR=”RoyalBlue”]it shows error in last line that “Object expected” where i need to define a object please help[/COLOR]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@redhatlookMay 30.2007 — i need to see all your code
Copy linkTweet thisAlerts:
@sumeetworkauthorMay 30.2007 — var slideInUse = new Array();

function Slide(objId, options) {

this.obj = document.getElementById(objId);

this.duration = 1;

docObj = document.getElementById(objId);
[COLOR="Red"]this.height = parseInt(getComputedStyle(docObj, "").getPropertyValue("height")); [/COLOR]
alert(height);
if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
if(this.options.duration) { this.duration = this.options.duration; }


this.up = function() {

this.curHeight = this.height;

this.newHeight = '1';

if(slideInUse[objId] != true) {

var finishTime = this.slide();

window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);

}

}

this.down = function() {
this.newHeight = this.height;
this.curHeight = '1';
if(slideInUse[objId] != true) {
this.obj.style.height = 'auto';
this.obj.style.display = 'block';
this.slide();
}
}

this.slide = function() {
slideInUse[objId] = true;
var frames = 30 * duration; // Running at 30 fps

var tIncrement = (duration*1000) / frames;
tIncrement = Math.round(tIncrement);
var sIncrement = (this.curHeight-this.newHeight) / frames;

var frameSizes = new Array();
for(var i=0; i < frames; i++) {
if(i < frames/2) {
frameSizes[i] = (sIncrement * (i/frames))*4;
} else {
frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
}
}

for(var i=0; i < frames; i++) {
this.curHeight = this.curHeight - frameSizes[i];
window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
}

window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);

if(this.options.onComplete) {
window.setTimeout(this.options.onComplete, tIncrement * (i-2));
}

return tIncrement * i;
}

this.finishup = function(height) {
this.obj.style.display = 'none';
this.obj.style.height = height + 'px';
}

return this;

}

////////////////////////////////////////////////////////////////////

[COLOR="RoyalBlue"]the code used in HTML on link is: [/COLOR]

[COLOR="SeaGreen"]<a href="javascript:Slide('mydiv').up();">Hide Comments</a>

<a href="javascript:Slide('mydiv').down();" class="current">View Comments</a> [/COLOR]
Copy linkTweet thisAlerts:
@redhatlookMay 30.2007 — I can't help you because i have no idea in which context is used for example [I]this[/I] operator in Slide() function, secondly i can't imagine which object has properties such as height, curHeight etc.
Copy linkTweet thisAlerts:
@Mega69May 30.2007 — Try with this:
<i>
</i>this.height = document.defaultView.getComputedStyle(obj, null).getPropertyValue("height")


You don't need to use parseInt.

Then, replace this:

window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);

with this:

window.setTimeout(function() { new Slide(objId).finishup(this.height); },finishTime);

Obviously, getComputedStyle doesn't work in IE.
Copy linkTweet thisAlerts:
@sumeetworkauthorJun 01.2007 — it does'nt solve anything

m still getting the mesg [B]document.defaultView[/B] and by putting this code the div open/ close in a flash it does'nt scroll anymore.

anyways thanks and suggest if some other script help.
×

Success!

Help @sumeetwork spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...