It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Change DIV

Change DIV

Postby moiseszaragoza on Wed Mar 14, 2007 5:00 pm

Ok this is what i am trying to do.

I have a timer. and after 1 sec i want display a div.

my code:
Code: Select all


<script type="text/javascript">
<!--
function delay(){
    alert("New var")
   document.div.Temp1.style=""
// At this time i need to we need to show the content of the div

}
//-->
</script>

<body onLoad="setTimeout('delay()', 1000)">
<!-- calls the JavaScrip Junction (Works) -->

<div id="Temp1" style="display:none">
XXXXXXXXXXXXX
</div>


moiseszaragoza
 
Posts: 5
Joined: Wed Mar 14, 2007 4:58 pm

Postby mwa103 on Wed Mar 14, 2007 7:25 pm

I found this script a while back, but can't remember where. The getStyleObject method takes an id and returns the object and the changeDiv changes the div from display: none to display: block (or block to none). Just add these to your head and then add
Code: Select all
changeDiv("Temp1", "block");
to your code.

Code: Select all
//Returns an element in document with passed id (objectId)
function getStyleObject(objectId) {
  if (document.getElementById && document.getElementById(objectId)) {
    return document.getElementById(objectId).style;
  } else if (document.all && document.all(objectId)) {
    return document.all(objectId).style;
  } else {
    return false;
  }
}

//Changes the_div's display property to the_change (block or none)
function changeDiv(the_div,the_change)
{
  var the_style = getStyleObject(the_div);
  if (the_style != false)
  {
    the_style.display = the_change;
  }
}


Post back if you have any questions.

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm


Who is online

Users browsing this forum: No registered users and 7 guests