|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
JavaScript - Using javascript to clip
I'm trying to get this clipping thing to work and have so far been unsuccessful through javascript. It throws an error at the highlighted red saying "style is null or not an object". Any ideas on what I'm doing wrong here?
Code:
var topVal=40;
var rightVal=105;
var bottomVal=40;
var leftVal=105;
var endInt2 = null;
function closeIt(id) {
var width= 210;
var height= 80;
var layered = document.getElementById(id).style;
if(leftVal > 0){
topVal+=0;
rightVal+=0;
bottomVal+=0;
leftVal-=20;
layered.style.clip="rect("+topVal+"px "+rightVal+"px "+bottomVal+"px "+leftVal+"px)";
endInt2 = setTimeout("closeIt('ctl00_ContentPlaceHolder3_Image1')",80)
}else{
alert(topVal+" "+rightVal+" "+bottomVal+" "+leftVal);
endTimer2();
}
}
function endTimer2(){
clearTimeout(endInt2);
}
|
|
#2
|
||||
|
||||
|
I'm not sure if this is the cause but you are setting the variable layered = document.getElementById(id).style:
Code:
var layered = document.getElementById(id).style; You are then trying to reference the style attribute of the layered variable: Code:
layered.style.clip="rect("+topVal+"px "+rightVal+"px "+bottomVal+"px "+leftVal+"px)";
Which in essence is saying: Code:
document.getElementById(id).style.style.clip="rect("+topVal+"px "+rightVal+"px "+bottomVal+"px "+leftVal+"px)";
|
|
#3
|
|||
|
|||
|
Quote:
Bingo!! Thanks S_O_S...... |
|
#4
|
||||
|
||||
|
Quote:
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > JavaScript - Using javascript to clip |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|