JavaScript - Visible Div Disappears When Clicking On Second Div
Hi,
After much searching and head-scratching (JS is not my forte!), I adapted some code to do what I want - well, almost! So here I am back again. I need to have three divs on a page, with each separate div changing onClick. Below is the code so far. Two problems: 1) when I open it in a browser window both divs show, then the one disappears when I click on the second div leaving only the numbers. How can I change it so that both divs remain open? 2) Instead of the numbers [1], [2], etc. to change the divs, I'd like to have to just click on one single 'click here for more' to display the next div then return to the first after the last one. Can this be integrated or is it too late? Thank you! Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <html> <head> <title>Switching Divs</title> <style> #one {width: 500px; height: 100 px; border: 1px solid red; } #two {width: 500px; height: 100px; border: 1px solid blue; } #three {width: 500px; height: 100px; border: 1px solid purple; } #four {width: 500px; height: 100px; border: 1px solid green; } #five {width: 500px; height: 100 px; border: 1px solid red; } #six {width: 500px; height: 100px; border: 1px solid blue; } #seven {width: 500px; height: 100px; border: 1px solid purple; } #eight {width: 500px; height: 100px; border: 1px solid green; } #propertyfrance {float: left; color: #666666; font-family: tahoma arial, verdana, sans-serif; font-size: 11px; } .propertytext {float: left; clear: right; width: 300px; height: 100px; border: 1px solid #000; } .propertyphoto {float: left; width 200px; height: 100px; border: 1px solid #cceeff; text-align: center; } #image-switch #one { padding:0px; } #image-switch #two, #image-switch #three, #image-switch #four { display:none; } #image-switch #five { padding: 0px; } #image-switch #six, #image-switch #seven, #image-switch #eight { display:none; } </style> <script type="text/javascript"> function switch1(div) { if (document.getElementById('one')) { var option=['one','two','three','four', 'five', 'six', 'seven', 'eight']; for(var i=0; i<option.length; i++) { obj=document.getElementById(option[i]); obj.style.display=(option[i]==div)? "block" : "none"; } } } </script> </head> <body> <h4>Switching divs (javascript)</h4> <div id="image-switch"> <br>OnClick <br> <div id="one"> <div class="propertytext">We'll get some text in here for property 1</div> <div class="propertyphoto"><img src="property1.jpg" height="100" width="180" alt="Property 1"></div> </div> <div id="two"> <div class="propertytext">We'll get some text in here for property 2</div> <div class="propertyphoto"><img src="property2.jpg" height="100" width="180" alt="Property 2"></div> </div> <div id="three"> <div class="propertytext">We'll get some text in here for property 3</div> <div class="propertyphoto"><img src="property3.jpg" height="100" width="180" alt="Property 3"></div> </div> <div id="four"> <div class="propertytext">We'll get some text in here for property 4</div> <div class="propertyphoto"><img src="property4.jpg" height="100" width="180" alt="Property 4"></div> </div> <br> <a onClick="switch1('one');"> [1]</a> <a onClick="switch1('two');"> [2]</a> <a onClick="switch1('three');"> [3]</a> <a onClick="switch1('four');"> [4]</a> <br><br> <div id="five"> <div class="propertytext">We'll get some text in here for property 5</div> <div class="propertyphoto"><img src="property5.jpg" height="100" width="180" alt="Property 5"></div> </div> <div id="six"> <div class="propertytext">We'll get some text in here for property 6</div> <div class="propertyphoto"><img src="property6.jpg" height="100" width="180" alt="Property 6"></div> </div> <div id="seven"> <div class="propertytext">We'll get some text in here for property 7</div> <div class="propertyphoto"><img src="property7.jpg" height="100" width="180" alt="Property 7"></div> </div> <div id="eight"> <div class="propertytext">We'll get some text in here for property 8</div> <div class="propertyphoto"><img src="property6.jpg" height="100" width="180" alt="Property 8"></div> </div> <br> <a onClick="switch1('five');"> [5] </a> <a onClick="switch1('six');"> [6] </a> <a onClick="switch1('seven');"> [7] </a> <a onClick="switch1('eight');"> [8] </a> </div> </body> </html> Similar TutorialsHello everyone! I'm a student and am trying to write some very simple code. My problem is I use innerHTML in my script file to send some text to a div in my html. When it's sent it renders and then quickly disappears. I've attached my code. Any help is dearly appreciated. There are two separate "files" .html & .js: Code: <?xml version = "1/0" encoding = "utf-8"?> <!DOCTYPE html Public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns = "http://www.w3.org/1999.xhtm"> <head> <!-- --> <!-- CS111 Quiz --> <title>CS111 Quiz</title> <script text = "text/javascript" src = "script.js"> </script> </head> <body> <h1 align="center">Mike Overholt</h1> <br/> <br/> <form id="answers" name="answers" onSubmit="return quiz();"> <table width="100%"> <tr> <td align="center"><h3>1. What is 1+1?</h3></td> <td align="center"><h3>2. What is 2+2?</h3></td> <td align="center"><h3>3. What is 3+3?</h3></td> </tr> <tr> <td align="center"> <input type="text" id="1" name="answer1" value=" " align="center"/> </td> <td align="center"> <input type="text" id="2" name="answer2" value=" " align="center"/> </td> <td align="center"> <input type="text" id="3" name="answer3" value=" " align="center"/> </td> </tr> <tr> <td align="center"> </td> <td align="center"> <input type="submit" id="submit" name="submit" value="submit" onClick="quiz();" align="center"/> </td> <td align="center"> </td> </tr> </table> </form> <div id="div1" align="center" name="answer_box" style="border:2px; border-color:gray; border-style:solid; width:50%; margin-left:auto; margin-right:auto; height:200px;"> <p id="p1"></p><br/> <p id="p2"></p><br/> <p id="p3"></p> <!--<script>alert(1);</script>--> </div> </body> </html> //script.js //Mike Overholt //Quiz 1 function quiz() { var i=1; var ans=new Array(); ans[1]=2; ans[2]=4; ans[3]=6; for(i=1;i<ans.length;i++) { var a=document.getElementById("p"+i); if(document.getElementById(i).value==ans[i]) { a.innerHTML="You answered number "+i+" correctly!"; } else { alert("You answered number "+i+" incorrectly, please try again."); } } } Here's a noodle-scratcher: I have a jwplayer in my page, and I've placed a short text describing it underneath it. Works fine in FF and Chrome, but in IE the text vanishes after you click the "Allow blocked content" permissions to allow activex controls. This is what it looks like: Code: <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='450' height='277' id='single1' name='single1'><param name='movie' value='jwplayer/player.swf'><param name= 'allowfullscreen' value='false'><param name='allowscriptaccess' value='always'><param name= 'wmode' value='transparent'><param name='flashvars' value='file=myVideo.f4v&autostart=true'> <embed id='single2' name='single2' src='jwplayer/player.swf' width='450' height='277' allowscriptaccess='always' allowfullscreen='false' flashvars='myVideo.f4v &autostart=truevolume=50'/> <br/> Here is my description text.<br/> If I place the text above the object, then it shows up fine. I'd rather not put it there, but I can if I can't figure the problem out. Any thoughts? Why is IE destroying my text? Thanks as always, ~gyz Would anyone know why (and the fix) when I place my cursor over the scrolling thumbnails under the main slideshow rotator on my site they "disappear"? http://americanwebmakers.com/demo_college Thanks in advance! Hello, I am having the problem that a javascript code runs from the start (Since I open the page). My page works by divs and not web pages so they change by the div visibility. This is the code for the divs: Code: function toggleVisibility(selectedTab) { // Get a list of your content divs var content = document.getElementsByClassName('content'); // Loop through, hiding non-selected divs, and showing selected div for(var i=0; i<content.length; i++) { if(content[i].id == selectedTab) { content[i].style.display = 'block'; } else { content[i].style.display = 'none'; } } } So each DIV has a function to make it visible by posting: "toggleVisibility(div);" I am trying to run a javascript code inside this function so that when a certain div becomes available the javascript code autoruns but whenever I post the javascript code inside the function it ignoresthat and runs since the web page loads. My example code would be: Code: function div(){ toggleVisibility('div2'); "RUN JAVASCRIPT CODE HERE" } Please help Reply With Quote 01-22-2015, 09:42 AM #2 felgall View Profile View Forum Posts Visit Homepage Master Coder Join Date Sep 2005 Location Sydney, Australia Posts 6,745 Thanks 0 Thanked 666 Times in 655 Posts Stick the code to run when a div becomes visible in a separate function. If the code is different for different divs then create separate functions. Let's assume that the function containing the code to run when div2 is visible is called func2. Let's also add func1 for when div1 is visible so you can see how it works for different functions for different divs. We'll also assume div3 can use the same function as div1 so you can see how functions can be shared We then amend the toggle function slightly as follows: Code: function toggleVisibility(selectedTab, func) { // Get a list of your content divs var content = document.getElementsByClassName('content'); // Loop through, hiding non-selected divs, and showing selected div for(var i=0; i<content.length; i++) { if(content[i].id == selectedTab) { content[i].style.display = 'block'; func(selectedTab); } else { content[i].style.display = 'none'; } } } Your code to call the toggle now gets changed to: Code: function func1(selectedTab) { "RUN JAVASCRIPT CODE FOR WHEN selectedTab IS MADE VISIBLE HERE" } function func2() { "RUN JAVASCRIPT CODE FOR WHEN div2 IS MADE VISIBLE HERE" } function div(){ toggleVisibility('div2', func2); toggleVisibility('div1', func1); toggleVisibility('div3', func1); } Hi, I have existing code that works in IE6 but not in IE8. My jsp page has a table on it and every record in that table has a link displayed as short string. Once you click on the link, the popup is displayed. The problem happens when the table has many records, the page becomes scrollable. So if you click on eg. first 10 links you can see the popup, but further down you go, the popup moves down as well and it finally disappears from the screen. It is still there just not visible. In IE6 it also moves but it stops at the bottom of the screen. The code that is used for displaying popup: var iGlobalPopup = window.createPopup(); //if this is for IE if (isIEBrowser()) { // Create the popup window var lPopupDocument = iGlobalPopup.document; // Create the html outline for the popup window var lHtml = "<html><head>" + "<div class='descTitle'>" + aTitle + "</div>" + lSpan.innerHTML + "</div>" + "</body></html>"; // Write the html to the popup window lPopupDocument.open( "text/html", "replace" ); lPopupDocument.write( lHtml ); lPopupDocument.close(); var lXPos = window.event.x; var lYPos = window.event.y; // Show the window iGlobalPopup.show(lXPos, lYPos, 400, 200, document.body); What can I do to keep the popup visible on the screen? Any help greatly appreciated. So it took me forever but I finally found a floating menu that works with a horizontally scrolling page - but of course, there's still a little bug. View the page he http://uconn.kappaphilambda.org/sisters.shtml As you can see, the more you scroll right, the more the menu "compacts" itself, eventually disappearing altogether. Any ideas as to how to fix it? You can view the code & script codes by viewing the source of the page. Thanks in advance :] Hello, On some pc's in IE my website shows disbehaviour with the popup-menu. When your mousepointer hoovers over the transparent border, the popupmenu disappears. Please check http://www.exintec.nl/test. Perhaps if you visit the website with Internet Explorer you can see what I mean, but it might be showing good as well. The menu is made with very little javascript and mainly CSS. I discovered the begin of the cause: when I don't use a transparent color for the border, it works fine. Also when I remove the underlying image (the sky-image) and still use transparent color it also works fine. How can this be? Using Z-index for the popup-window/menu and give it a real high number won't work. I really don't see it. Ofcourse I want to keep using the transparent color and the underlying image. ------------------- Source code HTML: --------------------- <ul id="menu"> <li onmouseover="toonPopUpMenu1()" onmouse-out="verwijderPopUpMenu1()"><a href="index.html" class="selected">OVER E<font co-lor="#548DD4">X</font>INTEC</a></li> <li onmouseover="toonPopUpMenu2()" onmouse-out="verwijderPopUpMenu2()"><a href="afdelingen.html">DIENSTEN</a></li> <li onmouseover="toonPopUpMenu3()" onmouse-out="verwijderPopUpMenu3()"><a href="waterstof_injectie.html">PROJECTEN</a></li> <li><a href="werkwijze.html">WERKWIJZE</a></li> <li><a href="contact.html">CONTACT</a></li> </ul> <ul id="popupmenu1" onmouseover="toonPopUpMenu1()" onmouse-out="verwijderPopUpMenu1()"> <li><a href="index.html" class="selected">Bedrijf</a></li> <li><a href="visie.html">Visie</a></li> <li><a href="missie.html">Missie</a></li> </ul> ----------- CSS-code ----------- #popupmenu1 { position: absolute; top: 25px; left: 141px; color: #FFFFFF; display: none; } #popupmenu1 li { border-bottom: solid transparent 4px; list-style-type: none; } #popupmenu1 li a { padding-left: 4px; padding-right: 0px; padding-bottom: 1px; padding-top: 1px; background-color: #000000; display: block; width: 155px; height: 20px; text-decoration: none; text-align: left; font-weight: 400; color: #FFFFFF; line-height: 20px; } #popupmenu1 li a.selected { font-weight: 900; } #popupmenu1 li a:hover { font-weight: 900; color: #FFFFFF; } ----------------- JS: ----------------- function toonPopUpMenu1() { var PopUpVenster=document.getElementById('popupmenu1'); PopUpVenster.style.display = 'block'; } function verwijderPopUpMenu1() { var PopUpVenster=document.getElementById('popupmenu1'); PopUpVenster.style.display = 'none'; } Hi - I hope someone can help me out, I've pored over this problem for hours. The site is http://www.spacemodel.com. A doctype is set. The CSS for the navmenu is: Code: #menu { background:#262626 url(images/menu_bg.gif) repeat-x top; border-bottom:1px solid #230808; margin:0 20px; height: 49px; overflow: hidden; } #menu .mleft{background: url(images/menu_side.gif) no-repeat left; width: 100%; height: 100%;} #menu .mright{background: url(images/menu_side.gif) no-repeat right; width: 100%; height: 100%;} #menu ul { width:960px; height:100%; overflow:hidden; } #menu ul li { list-style:none; font-family:Arial, sans-serif; font-weight: 700; line-height: 49px; color:#E6E6E6; font-size:11px; text-transform:uppercase; text-align:center; background:url(images/menu_side.gif) no-repeat right 0; margin:0 0 0 25px; padding: 0 25px 0 0; } #menu a:link,#menu a:visited,#menu a:active,#menu a:hover { color:#E6E6E6; text-decoration:none; } Works fine in all other browsers and versions. Affects about 5% of visitors, but one is my client All help and insight appreciated! Laurie hy. i have menu further construction Code: <ul id="menu" class="menu"> <li><a href="#">item 1  </a></li> <li><a href="#">item 2  </a></li> <li><a href="#">item 3</a> <ul id="submenu" class="submenu"> <li><a href="#">item 3 sub 1</a></li> <li><a href="#">item 3 sub 2</a></li> </ul> </li> </ul> and my function to open my on obscure menu then mouse over to element teg a Code: function doMenu (li){ var oli = li.childNodes; var len = oli.length; if (len > 1) { for (var i = 0; i < len; i++) { if (oli[i].nodeType == 1) { if (oli[i].tagName == 'UL') { return oli[i]; }}}} }; function doShow(e) { if (e) { var t = e.target; console.log(t.tagName); var pN = t.parentNode; console.log(pN) if (pN.tagName == 'LI') { if (doMenu(pN)) { var oUl = doMenu(pN); if (oUl.style.display == "none") { oUl.style.display = "block" } else {oUl.style.display = "none"} }}}}; and my problem, then HTML page load full. I mouse over to element tag a and function at this moment not show element menu. why it so. Because then i start mouse over too, function start and menu show. who can explain me how it work. I have seveal flash quizzes set up for my history class. On the main page right now is just a link to quiz #1. After finishing quiz #1, I want a cookie set that is proof of a finished test. I will then redirect back to the main page that will now show a link to quiz #2. And so on after each quiz.... Any help would be greatly, greatly appreciated. I want 10 divs that have their visibility set to none. Then based on a cookie I would like to have 1 at at time become visible. If you goto http://jsfiddle.net/BT4Bk/ you can see that the dark bar is visible. This is padding for the #ajax div that will wrap the content inside. How do I hide the padding so its not displayed until it slides into view with the content? Say I have a gallery of 16 images and I have a menu for the gallery to sort the images by Most Viewed, Most Recent, Highest Rating, A-Z, Z-A.. if I were to click 1 of the menu links it will change the order of the images but is it possible to actually show the images MOVING into their new places? Looking for a jquery solution if possible.. if not still open to anythin that would work I am not sure if this is the proper place to ask this or not or even what to ask for. I am very new to this and this is just for learning. The code is not mine. The code is just a blue table with a bookmark option. When I remove the javascript code for the bookmark the blue table disappears. Can anyone tell me why that happens? Code: <html> <body> <table width="95%" align="center" cellpadding="0" cellspacing="0" bgcolor="#3399ff"> <tr bgcolor="#3399ff"> <td colspan="11" align="right" valign="middle" bgcolor="#3399ff"> <script language="javascript"> <!--blue area below tabs--> //This code is for IE v4 or better if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion >= "4.0") {document.write( "<SPAN class='bookmark' onClick='window.external.AddFavorite(location.href, document.title);'>*Bookmark this page*</SPAN>")} //This code posts text if not else {document.write("<span class='bookmark'>book mark this page</span>")} </script> </tr> </table> </body> </html> This is the code exactly how it was sent. I am trying to remove the bookmark option but keep the table the way it is. Anyone have any idea what I am doing wrong? Thank you very much Hello guys, The following excerpt is part of a very huge project(in terms of code involved). Pardon me if it lacks a bit of context. But I assume I have posted adequate information for understanding the problem. Code: var sztitlebar_specific= "<table cellpadding='0px' cellspacing='0px' width='100%'><tr>" +"<td class='tiletitle'>" "<img src='../images/alert.gif' onclick='toggleAlerts(\"#ID#\")' alt='Toggle Alerts' title='Toggle Alerts' style='cursor: hand'>" + "<input type='checkbox' name='pricesonlycb' onclick='parent.applyFilterPricesOnly(\"#ID#\",pricesonlycb.checked,mypricesonlycb.checked,\"#NAME#\")'>" + "<input type='checkbox' name='mypricesonlycb' onclick='parent.applyFilterPricesOnly(\"#ID#\",pricesonlycb.checked,mypricesonlycb.checked,\"#NAME#\")'>" + "<td class='tiletitle' style='text-align: center'>#NAME#</td>" + </tr></table>"; The onclick event fires without any trouble, and the following function is called. Code: function applyFilterPricesOnly(filterid, pricesonly, mypricesonly,filtername){ alert("applyFilterPricesOnly called: filterid =" + filterid + "filtername =" + filtername + "mypricesonly =" + mypricesonly + " pricesonly=" + pricesonly); } But when I alert the status of the checkboxes they show up as "undefined". As you can see, the first piece of code defines a titlebar with a button and a couple of checkboxes and the name of the titlebar. And it is these checkboxes that remain undefined even though I can see them and check and uncheck them. But the name of the titlebar gets passed to the function correctly when the onclick event fires and it gets alerted. Where am I going wrong? Hi I'm trying to create a questionnaire style series of radio buttons which are hidden and then a different set of radio buttons displayed depending on the previous answer. eg Q1 Is it a man? (if select yes then display) Q2 Is he called John? (if no then display) Q3 Is he called Gary? and so on... I've been testing using the code below but wondered if anyone had any ideas on how this could be done easily? Be grateful for any advice, Matt. Code: Is it a Man? <input type="radio" name="agree" value="y" onClick="toggle(this)" /> Yes <input type="radio" name="agree" value="n" onClick="toggle(this)" /> No <br /> <p id="continue"> <input type="radio" name="agree" value="y" onClick="toggle(this)" /> Yes <input type="radio" name="agree" value="n" onClick="toggle(this)" /> No </p> <script> var continue_button = document.getElementById('continue'); continue_button.style.visibility = 'hidden'; function toggle(switchElement) { if (switchElement.value == 'y') continue_button.style.visibility = 'visible'; else continue_button.style.visibility = 'hidden'; } </script> Hi, have table with 5 rows. First 2 rows visible. Last 3 rows hidden - Code: <tr id="row1" style="display: none"> <tr id="row2" style="display: none"> <tr id="row3" style="display: none"> With onclick would like to make those rows visible to user - how can I do that? thank - john Hello everyone, I have tried about 8 different variations of code to try to get this to work properly and cannot accomplish it. Please help if you can figure it out. I have 2 div's that are hidden. each div contains a FLV video, autostart=false. when button 1 is clicked, DIV 1 becomes visible and you may click on video to start playing it. When button 2 is clicked, DIV 1 goes to hidden and DIV 2 becomes visible with video 2. -- Ok so problem is this, the video that was playing in DIV 1 remains playing or at least the audio remains playing. If video 2 is started then you have 1 video source and 2 audio sources playing. I am trying to get the video in DIV 1 or DIV 2 to STOP or PAUSE when the DIV's state becomes hidden. here is the last code I tried below before frustration over come me. any suggestions would be great. Robert Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- #Layer1 { position:absolute; width:200px; height:115px; z-index:1; left: 13px; top: 47px; visibility: hidden; } #Layer2 { position:absolute; width:600px; height:645px; z-index:2; left: 14px; top: 47px; visibility: hidden; } --> </style> <script type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_showHideLayers() { //v6.0 var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } obj.visibility=v;} } function MM_popupMsg(msg) { //v1.0 alert(msg); } //--> </script> </head> <img src="chastain cd landing pages/atlanta-ga-carpet-upholstery-cleaning.com/images/phone.jpg" alt="Button to Display DIV 1" width="27" height="22" onclick="MM_showHideLayers('Layer1','','show','Layer2','','hide')" /> <img src="chastain cd landing pages/atlanta-ga-carpet-upholstery-cleaning.com/images/spacer.gif" width="60" height="1" /> <img src="chastain cd landing pages/atlanta-ga-carpet-upholstery-cleaning.com/images/phone.jpg" alt="Button to Display Div 2" width="27" height="22" onclick="MM_showHideLayers('Layer1','','hide','Layer2','','show')"/> <div id="Layer1">VIDEO 1 <object id="player1" type="application/x-shockwave-flash" width="600" height="600" wmode="transparent" data="http://www.dryconcepts.com/videos/flvplayer.swf?file=http://www.dryconcepts.com/videos/video1.flv&autoStart=false"> <param name="movie" value="http://www.dryconcepts.com/videos/flvplayer.swf?file=http://www.dryconcepts.com/videos/video1.flv&autoStart=false" /> <param name="wmode" value="transparent" /> </object> </div> <div id="Layer2">VIDEO 2 <object id="player2" type="application/x-shockwave-flash" width="600" height="600" wmode="transparent" data="http://www.dryconcepts.com/videos/flvplayer.swf?file=http://www.dryconcepts.com/videos/video1.flv&autoStart=false"> <param name="movie" value="http://www.dryconcepts.com/videos/flvplayer.swf?file=http://www.dryconcepts.com/videos/video1.flv&autoStart=false" /> <param name="wmode" value="transparent" /> </object> </div> </body> </html> Hi As title says : "How to hide div so his content won't be loaded until he is visible?" And is it possible to add preloader for that div? Hi, I'm having trouble figuring out why my image is disappearing when the user clicks on the arrow image to expand text for viewing. The arrow image only disappears if the link text is is more than one line. It remains if the link is only one line of text. Here is the code: HTML code: Code: <div class="ws-webpart> <div class="hidecat1"></div> <div class="hidecat1"> <!--This comment line added please dont remove this comment line --> <a class="hidecat2" id="za0.91" onclick="showHide('a0.91')" href="javascript:void(0)">Lorem ipsum dolor sit amet</a> </div> <div style="display:none;" id="a0.91"> <!--This comment line added please dont remove this comment line --> <div class="hideqst1"> <a id="sb0.913.92" class="hideqst2" onclick="showHide('b0.913.92')" href="javascript:void(0)"> Sed lectus lectus, varius quis vestibulum non, molestie vel est. Integer enim quam, elementum vel ornare non, egestas non augue. Ut varius vulputate mi, </a> </div> <div style="display:none;" id="b0.913.92"> <!--This comment line added please dont remove this comment line --> <div class="hideAns"> <p>Fusce suscipit tempus magna eget eleifend. Ut lacinia, turpis ac tempus euismod, nulla ipsum vehicula sem, et laoreet augue nunc in neque. Maecenas porttitor lacinia risus, et rhoncus felis vestibulum eget. Sed nec turpis nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In fringilla mollis leo sed auctor. </p> </div> </div> <div class="hideqst1"> <a id="sb0.9134.65" class="hideqst2" onclick="showHide('b0.9134.65')" href="javascript:void(0)"> Integer non urna vel ligula interdum?</a> </div> <div style="display:none;" id="b0.9134.65"> <!--This comment line added please dont remove this comment line--> <div class="hideAns"> <p>Suspendisse pretium gravida tortor, id blandit elit hendrerit porttitor. Mauris at purus id neque mollis placerat vitae in tortor. Morbi porta tincidunt sagittis. Nam quis augue justo, id euismod nisl.</p> <p>• Donec sit amet urna felis. Praesent at erat ligula, eget porttitor diam.<br> • Quisque quis sapien leo. Proin sit amet sem et lectus gravida iaculis a non turpis. Vivamus at metus quis odio mattis </p> </div> </div> </div> CSS code: Code: div.ws-webpart{margin-bottom:15px;clear:both;} .ws-webpart.hidecat1{padding-top:7px;} .ws-webpart.hidecat2{padding-left:2.2ex;color:#000;font-weight:700;text-decoration:underline;background:url(../images/layout/link_arrow.gif) no-repeat 0 3px;} .ws-webpart.hidecat3{padding-left:2.2ex;color:#000;font-weight:700;text-decoration:none;background:url(../images/layout/link_arrow_down.gif) no-repeat 0 3px;} .ws-webpart.collapseqst1{padding-top:7px;padding-left:2.2ex;} .ws-webpart.hideqst2{padding-left:2.2ex;color:#7C902C;padding-right:0;background:url(../images/layout/link_arrow.gif) no-repeat 0 3px; zoom:1;} .ws-webpart.hideqst3{padding-left:2.2ex;color:#7C902C;padding-right:0;background:url(../images/layout/link_arrow_down.gif) no-repeat 0 3px;} .ws-webpart.hideAns{color:#000;padding-left:4.4ex;padding-right:1.5ex;padding-top:7px;} Javascript code: Code: <script language="javascript" > // Function for Collapsible Link function showHide(ID) { if (document.getElementById(ID).style.display == "block"){ document.getElementById(ID).style.display = "none"; if(ID.charAt(0)=="a"){ document.getElementById("z"+ID).className="hidecat2"; } if(ID.charAt(0)=="b"){ document.getElementById("s"+ID).className="hideqst2"; } } else { document.getElementById(ID).style.display = "block"; if(ID.charAt(0)=="a"){ document.getElementById("z"+ID).className="hidecat3"; } if(ID.charAt(0)=="b"){ document.getElementById("s"+ID).className="hideqst3"; } } } </script> I have attached the images. Thanks in advance |