JavaScript - Text Disappears When Placed After An Object In Ie
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 Similar TutorialsHi, 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 hi all, I have a simple website with 2 Frames, In top frame I have a button that invokes CGI script and internally that CGI script prints info (text) into the bottom frame. Going further we want to print the output coming from CGI into a textarea object in bottom form. I have a function in my CGI script: But ends up printing multiple textarea objects in lower frame. We want to print each line of text into the same textarea object in lower frame. and at the end display a new button. How can we do this using javascript/CGI? I tried the following but not displaying anything. sub print_message { my($message1, $message2) = @_; my $final_message = $message1 . " " . $message2; print <<END_HTML; <html> <head> <form name="myform"> <table border="0" cellspacing="0" cellpadding="5"> <tr> <td><textarea name="outputtext" rows="10" cols="100"> $final_message </textarea> </td> </tr> </table> </form> <style> <!-- a{font-weight:bold;font-family:arial;text-decoration:underline;font-size:13px;} a:hover{font-weight:bold;font-family:arial;text-decoration:none;font-size:13px;} // --> </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <a href="main.html" rel="nofollow" target="bottom"></a> <title>CTS Debug Information</title> <style type="text/css"> img {border: none;} </style> </head> <body> </body> </html> END_HTML I created this function in javascript: <script language="javascript" type="text/javascript"> function addtext() { var newtext = document.myform.outputtext.value; var nextLineTextNode = document.createTextNode(newtext + "\r\n"); var logData = document.getElementById("outputtext"); logData.appendChild(nextLineTextNode); logData.scrollTop = logData.scrollHeight - logData.clientHeight; } </script> But when i implemented in my CGI nothing is printed. Thanks!!! Hi there, this is my first post. I'm very new to javascript and have been programming a "beer counter" that simply counts +1 into a text object after every click. After I got this to work I copied the code in order to make a clear button / function. I've been having problems, even though the code seems to be identical. This is likely an obvious question, pardon my inexperience. <html> <head> <title>Beer Counter</title></head> <body><script language="Javascript"> var beers = 0 var output ="" function beer() { beers = beers + 1 output = document.getElementById('output') output.value = beers } function clear() { beers = 0 output = document.getElementById('output') output.value = beers } </script> <input type='button' value='Crush' onclick='beer()'; /> Beer count:</input> <input type='text' id='output' name='output'; /><br/> <input type='button' value='Clear' onclick='clear()'; /> </body> </html> Hello 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."); } } } 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> 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! Hi, every time I try and alert: [ { number:0, secondnumber:0 }, { number:2, secondnumber:1 }, { number:1, secondnumber:2 } ] it just shows [object object], [object object], [object object]. Why is this and what can I do to make the record be shown as it is above in an alert? Thanks. I can't get any info from Firebug except that one line, uncaught exception [object Object]. The code fully worked, then I needed to make it dynamically create Sortables from the scriptaculous library based on how many X were in a table in my database, which I've done, and I'm thinking it may be a simple slight parse error of some type, I'm not too good with Javascript, because now my script barely works. I've double checked the script's source code, the PHP variables are exactly what they should be. Code: print<<<HERE Sortable.create('sortlist$box', { tag: 'img', overlap:'horizontal',constraint:false, containment: $list, dropOnEmpty: true, onChange: function(item) { var list = Sortable.options(item).element; if(changeEffect) changeEffect.cancel(); changeEffect = new Effect.Highlight('changeNotification', {restoreColor:"transparent" }); }, onDrop: function(item) { var thing=Sortable.options(item).element.identify(); var anchors = document.getElementById(thing).childNodes.length-2; if(anchors > 20){ alert('This box had 20 creatures in it already, your last action has not been saved.'); window.location.reload(); } else{ new Ajax.Request("saveImageOrder.php", { method: "post", parameters: { data: Sortable.serialize("sortlist$box") } }); } } }); HERE; $box++; } ?> }); </script> if you solve this I'll send ya $10 via paypal I created a method for displaying an object's properties: Code: renderfunction = false; function showProperty (object, property) { document.write ('<td class="type">' + (typeof object[property]) + '</td>' + '<td class="name">' + property + '</td>'); document.writeln('<td class="value">' + ( (typeof object[property] != 'function') ? object[property] :( (property != 'showProperties') ? ( renderfunction ? object[property]() : ('<span class="self">NOT RENDERED</span>') ) : ('<span class="self">THIS</span>') ) ) + '</td>'); document.writeln('<td class="hasOwnProperty" >' + ( object.hasOwnProperty(property) ? "Local" : "Inherited" ) + '</td>'); if (typeof object[property] == 'function') { document.writeln ('<td class="function">' + object[property] + '</td>'); } else { document.writeln ('<td class="function"> </td>'); } } As long as renderfunction = false, the object is fine coming out of this function. However, if I change renderfunction to true, all my properties become undefined. Why isn't this working as I expect it to? How should I fix it? Thanks in advance, -Brian. 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'; } 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 :] 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. 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 together! I generate html code with jsp. In that jsp there a several framesets and frames. And yes i know, frames are not really up to date but it's an old program and i have to deal with it now. Anyway, in the top frameset i have an onload attribute like onload="load()". In the function load i want to access the Element.prototype object. But unfortunately typeof Element gives me "undefined". So i looked a little deeper and found that window.toString() gives me "[object]" and not as expected "[object window]" so somehow my window doesn't know that its construcor is Window. window.construcor is "undefined" as well. And i don't have access to the Element object. I really don't know where the error could be. When the page is loaded and i access the same window over the console, then everything is right. But in my function a can't get access to the objects i need. I also don't know what part of the code could be useful to post here, but maybe someone had a similar problem before? i should say that this problem only occurs in IE8. In IE9 it works perfectly. Has anyone any idea?? Hi all, I'm stumped on finding a way in javascript to create an object factory whose instances are also object factories. In short I want something like that below, but no joy ... any clues? Code: function createClass () { return new createClass() function createClass() { return new createInstance () function createInstance () { //Default properties, values and methods which might later be extended } } } var createDoor = createClass(); var door1 = createDoor(); var door2 = createDoor(); var createChair = createClass(); var chair1 = createChair (); var chair2 = createChair (); I'm writing a program that involves a network of interconnected nodes (or simply objects in my example below). It depends on being able to access properties of an object's linked objects (a bit oddly worded, sorry)... Problem is I'm not sure how to properly access those properties... see below please. <script> //This is an example of a problem im having in my own code... //I want to access the name of the object within the links array wintin the object... var objA = {name: "Object A", links: [objB, objC]}; var objB = {name: "Object B", links: [objC, objD, objE]}; var objC = {name: "Object C", links: [objB]}; var objD = {name: "Object D", links: [objE]}; var objE = {name: "Object E", links: [objD]}; //ex: I want to access the name of Object A's first link... console.log(objA.links[0].name); </script> I'm hoping to get "Object B"... But instead I get: TypeError: Result of expression 'objA.links[0]' [undefined] is not an object. Is there another way around this? Any thoughts are appreciated. Ignore post (if mod, please delete)
I have a map with hotspots, and when you hover over a hot spot, a hidden DIV appears. Thanks to my favorite coding forum, this one, I was able to successfully accomplish this first bit of code. The only problem I'm having now is getting the DIV to remain open while I move my mouse from the hotspot to the DIV. As soon as I move my mouse away from the hotspot, the DIV disappears. I need to put links in the DIVs, and users will need to be able to move their mouse away from the hotspot to click on the link, but currently can't. I experimented with setTimeout, but didn't get too far. If anyone could help me, I'd appreciate it. I really need to get this working. Code: <img src="images/map.png" alt="" usemap="#map"/> <map id="map" name="map"> <area shape="rect" coords="211,84,225,97" href="#" alt=""/> <area shape="rect" coords="226,78,240,92" href="#" alt=""/> <area shape="rect" coords="353,66,376,89" href="#" alt=""/> </map> <div id="hidden"> <div class="location" style="left:25px; top:-290px;"> <img src="images/location01.jpg" alt=""/> </div> <div class="location" style="left:25px; top:-275px;"> <img src="images/location02.jpg" alt=""/> </div> <div class="location" style="left:275px; top:-285px;"> <img src="images/location03.jpg" alt=""/> </div> </div> <!-- #hidden --> Code: function show(which) { var area = document.getElementById("map").getElementsByTagName("area"); var locations = document.getElementById("hidden").getElementsByTagName("div"); for (var a=0; a < area.length; ++a) { if(area[a] == which) locations[a].style.display="block"; } } function hide() { var locations = document.getElementById("hidden").getElementsByTagName("div"); for (var d=0; d < locations.length; ++d) { locations[d].style.display="none"; } } function init() { var area = document.getElementById("map").getElementsByTagName("area"); for (var a=0; a < area.length; ++a) { area[a].onmouseover = function() { show(this); } area[a].onmouseout = hide; } } window.onload = init; Hello. Is there any way to get the variable name of an object from inside the object? E.g. PHP Code: function Bla(){ this.write = function(){ document.write(<objectname>); } } obj1 = new Bla(); obj1.write(); //Outputs obj1 Here is my script: PHP Code: function myTimer(seconds, obj){ this.seconds = seconds; this.obj = obj; this.startTimer = function(){ if(this.seconds>0){ this.seconds--; this.obj.innerHTML = this.seconds; this.timer = setTimeout("Timer.start()",1000); } } } Timer = new Timer(10, obj); Timer.startTimer(); Now the problem is that the variable that contains the object must be named "Timer". This way I cannot create new timer objects with different variable names I have tried: this.timer = setTimeout("this.start()",1000); but it doesn't work. That's why it would be good to detect the variable name and instead use something like this: this.timer = setTimeout(varname+".start()",1000); I would rather not have to pass the variable name through a parameter like this: Timer1 = new Timer(10, obj, "Timer1"); Thanks in advance. Quote: menu: function( a, b ) { $( b ).observe( 'click', function( event ) { event.stop(); if( $( a ).visible() ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); } else { $( a ).show(); $( b ).addClassName( 'selected' ); document.observe( 'click', function( e ) { if( e.target.id != a && e.target.id != b && !Element.descendantOf( e.target, $( a ) ) ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); } }); } }); $$( '#' + b + ' > a' ).each( function( element ) { element.observe( 'click', function( event ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); }); }); } This work's perfrect accept when i use it with others on the menu it leaves the other ones open, how do i get it to close the open one when i open a new menu.. Thanks. |