JavaScript - Node Object
I just really needed to know something about the whitespace between nodes in a tree structure.
I know that Firefox's, Safari's, Chrome's and Opera's DOM treat the whitespace as a node. I am wondering what nodeType whitespace would return? Thank you all for any help + sugestions. Similar Tutorialscan someone please help me to find out wahy I cant access the text value within the "author> tag using the following code? I get that "var y" is null. Thanks! Code: Content-type: text/html\n\n <html> <body> <book> <author>Moris</author> </book> <script type="text/javascript"> var x =document.getElementsByTagName("author")[0] var y = x.childNodes[0]; document.write(y.value) </script> </body> </html> i was wondering: Has anyone here has used Node.js on a production service, app, or site ? If so, what type of project was it, and how is it working out? I'm building a new media site at work using node, and have been blown away by what i've seen/tested so far. Swapping the LAMP stack for just linux and js has really opened my eyes to just how wrong i had been approaching the back-end for so long. Does anyone else have this experience, or am i the only one getting 1,000X performance increases with node? try serving half a million dynamic pages in one hour at 10% cpu and <20 megs of ram on a 5-year old compaq consumer desktop using php; i dare you... i guess the main question is that it's so literally awesome on the bench, will those number hold once it starts getting used by the public? In order to better understand the DOM data structure, I am trying to write a JavaScript that will produce something like HTML from the DOM data structure. My current problem is that when I include a <br> tag in my source HTML, it reports that its parent is undefined, and this is breaking my code. So, given the following code, why does the <br> tag report that it's parent is undefined. Code: <html> <head> <title>br.parent</title> <script type="text/javascript"> function brTest() { var jBR = document.getElementsByTagName("br")[0]; alert("<br>.nodeType = " + jBR.nodeType + "\n<br>.nodeName = " + jBR.nodeName + "\n<br>.ParentNode = " + jBR.ParentNode); } </script> </head> <body onload = "brTest();"> <p>Now is <br> the time.</p> </body> </html> Thanks for any help you can provide. Jerry Hi follks, i have a xml like this <t> <country>usa</country> <country>india</country> <country>china</country> <country>russia</country> <country>mexico</country> </t> im passing the node country alone in javascript function js:findcountry(//country) the function is like this findcountry(xmlnodecountry) { } what code i should use to send the node country alone to the javascript function. and how can i read and traverse thru the nodes i used xmlnodecountry.selectnodes but it didnt work. im not getting the node itself in xmlnodecountry edit: I further identified the problem. Hi, I'm new to JavaScript and I'm having problem with appending a div node returned from a function. Here's where it crashed: Code: var div=document.getElementById("dashboard_secondary_cat_list"); var s=get_secondary_cat_node(attributes); alert("b4 appendin:"+s); div.appendChild(s); alert("done appendin"); alert("done appendin"); never gets called because the previous line crashes. alert("b4 appendin:"+s); shows: b4 appendin:[object HTMLDivElement] Does anyone know of a good tutorial on how to make a good node.js chat? I need a chat that a decent VPS server can handle ~100 simultaneous users with and apparently I should be using node.js but have no experience with it. What should I look at? Thanks! Hello I am trying to iterate out the values of an xml file. I have got the file to load though I have not yet been able to extract the values. Considering that theXml is an xml file and 'coords' are tags containing a coordinate how would I extract the value. Here is the code I am using Code: var coordTags = theXml.getElementsByTagName( 'coords' ); var len =coordTags.length;///this works var coord =coordTags[0].value;///this doesn't work var coord =coordTags[0].text;///this doesn't work var coord =coordTags[0].innerText;///this doesn't work parent.document.receiver.theres.value = coord; I am sure for some of you this is a really simple question so please someone help!! Hey guys..... I've worked out how to get the value from a select option tag, but can't work out how to get the text inside the option tags. Here is the code I am using to get the value attribute from the option tag.. PHP Code: // Set the search results box var cats = document.getElementById('cat_list'); // Loop through categories from the search results select box for (i = 0; i < cats.length; i++) { // Check if the cat is selected if (cats.childNodes[i].selected == true) { // Set this category's values to some variables var cat_id = cats.childNodes[i].getAttribute('value'); } } Thanks! Hi, im having a little difficulty checking if an XML node has a value, here the code: var Divs=new Array("artist","bio","img","date","tickets","venue","street","city","country","headliner"); xmlDoc=xmlhttp.responseXML; for ( nodes in Divs ) { if(!xmlDoc.getElementsByTagName(Divs[nodes])[0].childNodes[0].nodeValue) { } else { document.getElementById(Divs[nodes]).innerHTML= xmlDoc.getElementsByTagName(Divs[nodes])[0].childNodes[0].nodeValue+"<br>"; } } This always throws up the error: document.getElementById(Divs[nodes]) is null ive tried putting the xmlDoc in a variable then checking if its null but no luck, also tried the same method against "undefined" but no luck either. Would be greatful if anyone has any suggestions. Thanks, Tom. Allow the search function to start anywhere within the name, rather than just at the start (so searching for "icha" would match "Richard". If more than 3 matches are found during the search don't display them just inform the user of the number of matches and suggest they search more precisely. Every time the user enters a "bad command", informs them of how many more they are allowed before they are locked out of the system. Introduce and implement an option to change a user's phone number. Reply With Quote 01-14-2015, 08:34 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts Look he http://www.codingforums.com/rules.htm And read rule 1.5 We do *NOT* do your homework for you. I will bet that the answer you got for "search array string" is too advanced. That is, your instructor will know immediately that it is not your own work. You need to *TRY* to do your homework yourself. If you get stuck on one particular point, where your code almost works but not quite, *THEN* is the time to ask a question. But you need to show your work so far. And, if you can, explain what is not working. ********* On a side note: How the heck is anyone here supposed to be able to help you with this part of the homework: Every time the user enters a "bad command", informs them ... You haven't even told us what a "command" is! If you *are* going to ask for help, you have to give enough information that someone can understand the question. But, again, don't expect help until you can (for example) at least show that your code is TRYING to process a "command". Same applies to Introduce and implement an option to change a user's phone number. You haven't bothered to show the data structure that even *HAS* phone numbers in it! Talk about incomplete information! I'm beginner, and there is a task in exam to change inner content of the second child node. Can't get, please help or maybe link to an article how to do it, because I can't find anything in my study book; edit: is this correct? function SetUpTranslation() { var phrases = document.getElementsByTagName('p'); for (var i=0; i < p.attributes.length; i++){ phrases.secondNode.innerHTML=french[i]; element.onclick=swapFE(phrases.secondNode); element.onmouseup=swapFE(phrases.secondNode); } } Hey, guys, my first post here on the forums, I hope this is the right place. This technically uses Javascript + PHP + XML, but the problem is more based on Javascript than the other two. That, and there are 380 people viewing Javascript and 8 people viewing XML, I decided to take the path of lesser resistance. Also, the code I used, I'm sure there are a million shortcuts that could be used. So if you can give me suggestions, I would Love to hear them because I'm still learning Javascript + PHP + XML and would be very grateful to learn how I could be more efficient What I'm creating is a Form that takes variables from an XML for users to fill out. Users can choose between products, and then when the product is clicked, it loads the options from an Array within the XML so... The question is Products Load from an Array Options Load from the chosen Products? I'm thinking this can be done two ways. Maybe a separate XML can be used for Options but then how would I link each one for each product? Or, can I load the Options in the same XML for each Product and load an array for each Product's Options? --- Later on, I need to figure out how to create a new element for each form the User fills out. IE They finish filling out the options and volume for 20 GI JOES. So it should save those Variables and the User Filled Variables. And then allow you to fill out a new product. Appending to the last form filled out IE 20 GI JOES [Color Red] [Eating Pizza] [Wearing Cowsuits] 12 BARBIES [Color Blue] [Eating Sushi] [Wearing Bearsuits] But I'll do my own reearch for that before I start asking here on how to do that --- This is my Code so far, some of you will recognize it from W3 Schools --- Code: JS oldTextAry = new Array(); var xmlDoc; if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open("GET","data.xml",false); xmlDoc.send(""); xmlDoc=xmlDoc.responseXML; } else if (ActiveXObject("Microsoft.XMLDOM")) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("data.xml"); } var x=xmlDoc.getElementsByTagName("PR");i=0; var y=xmlDoc.getElementsByTagName("OPTION");j=0; var z=xmlDoc.getElementsByTagName("OPT");k=0; var enl; Above Code, calls on data.xml in the same folder. It then creates an array from the XML for <PR> <OPTION> and <OPT>. In the XML. It's... Code: XML <PRODUCT> <PR> <TITLE>Title goes here</TITLE> <IMG>jpg html for image goes here</IMG> <ENL>jpg html for high res image goes here</ENL> <LINK>a link if needed</LINK> <INFO>more info if needed</INFO> <OPTION> <OPT>hearts</OPT> <OPT>stars</OPT> <OPT>horseshoes</OPT> <OPT>clovers</OPT> <OPT>balloons</OPT> </OPTION> </PR> <PR> <TITLE>Title goes here</TITLE> <IMG>jpg html for image goes here</IMG> <ENL>jpg html for high res image goes here</ENL> <LINK>a link if needed</LINK> <INFO>more info if needed</INFO> <OPTION> <OPT>hearts</OPT> <OPT>stars</OPT> <OPT>horseshoes</OPT> <OPT>clovers</OPT> <OPT>balloons</OPT> </OPTION> </PR></PRODUCT> The OPT is what I want to load as an array. How could I do that? So continuing with the JS code... Code: function productnext(){if (i<x.length-5) { i++; productline();return false; }} function productprevious(){if (i>0) { i--; productline();return false; }} function productline(){ ttl1=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl2=(x[i+1].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl3=(x[i+2].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl4=(x[i+3].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); ttl5=(x[i+4].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); img1=(x[i].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img2=(x[i+1].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img3=(x[i+2].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img4=(x[i+3].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); img5=(x[i+4].getElementsByTagName("IMG")[0].childNodes[0].nodeValue); lnk1=(x[i].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk2=(x[i+1].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk3=(x[i+2].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk4=(x[i+3].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); lnk5=(x[i+4].getElementsByTagName("LINK")[0].childNodes[0].nodeValue); inf1=(x[i].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf2=(x[i+1].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf3=(x[i+2].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf4=(x[i+3].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); inf5=(x[i+4].getElementsByTagName("INFO")[0].childNodes[0].nodeValue); opt1=(y[j].getElementsByTagName("OPT")[0].childNodes[0].nodeValue); opt2=(y[j+1].getElementsByTagName("OPT")[1].childNodes[0].nodeValue); opt3=(y[j+2].getElementsByTagName("OPT")[2].childNodes[0].nodeValue); opt4=(y[j+3].getElementsByTagName("OPT")[3].childNodes[0].nodeValue); opt5=(y[j+4].getElementsByTagName("OPT")[4].childNodes[0].nodeValue); enl1=(x[i].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl2=(x[i+1].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl3=(x[i+2].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl4=(x[i+3].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); enl5=(x[i+4].getElementsByTagName("ENL")[0].childNodes[0].nodeValue); The first two functions are for a list in the PHP. The rest of the code gives the first five products into respective variables for the PHP to use. Code: PHP <td width="25" rowspan="3"><a title="<b>Previous Product</b><br><br>Click to Scroll the product list left" onclick="productprevious();" style="cursor:pointer"><img src='prodprev.jpg' width="25" height="170"></a></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR1'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR2'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR3'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR4'></div></td> <td> </td> <td width="120" height="120" valign="top"><div id='PR5'></div></td> <td> </td> <td width="25" rowspan="3"><a title="<b>Next Product</b><br><br>Click to Scroll the product list right" onclick="productnext();" style="cursor:pointer"><img src='prodnext.jpg' width="25" height="170"></a></td> It's a line for five products. When people hit the Next button, it moves the Array one product over. And previous button does vice versa. Code: JS document.getElementById("PR1").innerHTML="<a href='javascript:void();' onClick='picture1();'><img src='"+img1+"' height=120 width=120></a>"; document.getElementById("PR2").innerHTML="<a href='javascript:void();' onClick='picture2();'><img src='"+img2+"' height=120 width=120></a>"; document.getElementById("PR3").innerHTML="<a href='javascript:void();' onClick='picture3();'><img src='"+img3+"' height=120 width=120></a>"; document.getElementById("PR4").innerHTML="<a href='javascript:void();' onClick='picture4();'><img src='"+img4+"' height=120 width=120></a>"; document.getElementById("PR5").innerHTML="<a href='javascript:void();' onClick='picture5();'><img src='"+img5+"' height=120 width=120></a>"; document.getElementById("PT1").innerHTML="<a href='javascript:void();' onClick='picture1();'>"+ttl1+"</a>"; document.getElementById("PT2").innerHTML="<a href='javascript:void();' onClick='picture2();'>"+ttl2+"</a>"; document.getElementById("PT3").innerHTML="<a href='javascript:void();' onClick='picture3();'>"+ttl3+"</a>"; document.getElementById("PT4").innerHTML="<a href='javascript:void();' onClick='picture4();'>"+ttl4+"</a>"; document.getElementById("PT5").innerHTML="<a href='javascript:void();' onClick='picture5();'>"+ttl5+"</a>"; return false;} This code places the products into the respective list. PR1 gets IMG1. This is also where I wonder if it could be more efficient, because I'm copying things five times in a row. There's got to be a better way to do that. Whenever it's clicked it operates a function called picture#() corresponding to the button. Once again... Must be a more efficient way. Code: function picture1() {document.getElementById('PI').innerHTML="<img src="+img1+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl1; /*test area, delete when done*/enl=enl1;document.getElementById("E").innerHTML=enl;} function picture2() {document.getElementById('PI').innerHTML="<img src="+img2+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl2; /*test area, delete when done*/enl=enl2;document.getElementById("E").innerHTML=enl;} function picture3() {document.getElementById('PI').innerHTML="<img src="+img3+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl3; /*test area, delete when done*/enl=enl3;document.getElementById("E").innerHTML=enl;} function picture4() {document.getElementById('PI').innerHTML="<img src="+img4+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl4; /*test area, delete when done*/enl=enl4;document.getElementById("E").innerHTML=enl;} function picture5() {document.getElementById('PI').innerHTML="<img src="+img5+" height=170 width=170>";document.getElementById('PTT').innerHTML=ttl5; /*test area, delete when done*/enl=enl5;document.getElementById("E").innerHTML=enl;} Above, places that picture into "PI" and gets the title and places it into "PTT" --- I was hoping to create another list. EXACTLY like I have here. Where the User can hit Next and Previous, using Options Loaded from an Array within the Array of Products. Is making a new XML with options the only way to do this? If that's the case, how do I associate each product with their options? Hi I discovered something weird that happend to me when trying to add a javascript created table to the document.body. Basically it doesn't add it in IE, but works fine in FF. Actually it does add it in IE, but only shows up if I add a <br/> later in a new statement... What?!?! try my code to see what is going on. (works fine in FF, does bad thing in IE) I tried to narrow the code i was working with down to basics and still have the glitch happen so maybe it's just something wrong with this code, but i couldn't pinpoint it. Also, it's only when i do document.body.appendChild(), not document.body.innerHTML += entireMassiveElement.innerHTML; I need it to work in both browsers with the appendChild() method, because innerHTML is much slower. Any advice appreciated! Thanks! 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> <title>Interace v1.0</title> <style type="text/css"> /****************** * --Panel Style ******************/ .panel { } .panel table td {padding: 0px;} .panel_corner { background-color: #00c0ff; background-repeat: no-repeat; width: 3px; height: 3px; } .panel_sideX {height: 3px; background-color: #00c0ff; background-repeat: repeat-x;} .panel_sideY {width: 3px; background-color: #00c0ff; background-repeat: repeat-y;} .panel_topLeft {background-position: 0px 0px;} .panel_topRight {background-position: -3px 0px;} .panel_bottomLeft {background-position: -0px -3px;} .panel_bottomRight {background-position: -3px -3px;} .panel_top {background-position: -3px -6px;} .panel_right {background-position: -3px 0px;} .panel_left {background-position: 0px 0px;} .panel_bottom {background-position: -3px -9px;} .panel_main { background-color: #00c0ff; } .panel_titlebar { color: #ffffff; font-family: verdana; font-size: 10pt; padding: 3px; padding-top: 0px; overflow: hidden; /* display: none; */ } .panel_title { float: left; height: 18px; overflow: hidden; } .panel_buttons { float: right; } .panel_toolbar { background-color: #444444; color: #eeeeee; font-family: verdana; font-size: 10pt; padding: 3px; overflow: hidden; display: none; } .panel_content { overflow: auto; font-family: arial; color: #eeeeee; font-size: 7pt; font-weight: bold; padding: 10px; border: 1px inset #cccccc; background-color: #444444; } </style> <!--///////////////////////////////////--> <script type="text/javascript"> function makeElement() { var layout = document.createElement("table"); //the table that is the basic layout var top = document.createElement("tr"); var tl = document.createElement("td"); top.appendChild(tl); var tc = document.createElement("td"); top.appendChild(tc); var tr = document.createElement("td"); top.appendChild(tr); var middle = document.createElement("tr"); var ml = document.createElement("td"); middle.appendChild(ml); var mc = document.createElement("td"); middle.appendChild(mc); var mr = document.createElement("td"); middle.appendChild(mr); var bottom = document.createElement("tr"); var bl = document.createElement("td"); bottom.appendChild(bl); var bc = document.createElement("td"); bottom.appendChild(bc); var br = document.createElement("td"); bottom.appendChild(br); layout.appendChild(top); layout.appendChild(middle); layout.appendChild(bottom); layout.style.borderCollapse = "collapse"; tl.className = "panel_corner panel_topLeft"; tc.className = "panel_sideX panel_top"; tr.className = "panel_corner panel_topRight"; tl.style.padding = "0px"; tc.style.padding = "0px"; tr.style.padding = "0px"; ml.className = "panel_sideY panel_left"; mc.className = ""; mr.className = "panel_sideY panel_right"; ml.style.padding = "0px"; mc.style.padding = "0px"; mr.style.padding = "0px"; bl.className = "panel_corner panel_bottomLeft"; bc.className = "panel_sideX panel_bottom"; br.className = "panel_corner panel_bottomRight"; bl.style.padding = "0px"; bc.style.padding = "0px"; br.style.padding = "0px"; //-- Set up the cursors for the bottom, right, and bottomright sides to resize mr.style.cursor = "e-resize"; bc.style.cursor = "s-resize"; // --Now create the internal structure, titlebar, toolbar, content area var main = document.createElement("div"); var titlebar = document.createElement("div"); var toolbar = document.createElement("div"); var content = document.createElement("div"); content.innerHTML = "success!"; main.appendChild(titlebar); main.appendChild(toolbar); main.appendChild(content); mc.appendChild(main); main.className = "panel_main"; titlebar.className = "panel_titlebar"; toolbar.className = "panel_toolbar"; content.className = "panel_content"; //-- create the titlebar internals, title, buttons, cleardiv var title = document.createElement("div"); var buttons = document.createElement("div"); var clear = document.createElement("div"); titlebar.appendChild(title); titlebar.appendChild(buttons); titlebar.appendChild(clear); clear.style.clear = "both"; title.className = "panel_title"; buttons.className = "panel_buttons"; main.style.width = "200px"; return layout; } function go(select) { var stuff = makeElement(); if(select == 1) { //-- Add everything to the container document.body.appendChild(stuff); } else if (select == 2) { //-- Add everything to the container //layout is a table, but innerHTML only returns the inner, so i just added on the outer tags. document.body.innerHTML += ('<table cellpadding="0" cellspacing="0">' + stuff.innerHTML + '</table>'); } //document.body.innerHTML += "<br/>"; } </script> </head> <body> <input type="button" value="test append Element" onclick="go(1);"/><input type="button" value="test innerHTML add" onclick="go(2);"/> <body> </html> I'm having a bit of a problem processing an OPML file to load into a list widget that's included in the WebOS development kit. Say I have an OPML file like: Code: <opml version="1"> <head> <title>News</title> </head> <body> <outline text="Local News" key="local"> <outline type="link" text="Some local Blog1" URL="http://local1.com"/> <outline type="link" text="Some local Blog2" URL="http://local2.com"/> </outline> <outline text="National News" key="national"> <outline type="link" text="Some national Blog1" URL="http://national1.com"/> <outline type="link" text="Some national Blog2" URL="http://national2.com"/> </outline> <outline type="story" text="Community" URL="http://directlinktostory1.com"/> <outline type="link" text="Classifieds" URL="http://directlinktostory2.com"/> <outline type="link" text="Download More News" URL="http://newsfeed.com/getmore.ashx"/> </body> </opml> I can put each text attribute into the list widget using: Code: var tree = transport.responseXML.getElementsByTagName('outline'); for( var i = 0; i < tree.length; i++ ) { curr = tree[i]; if (!curr.hasChildNodes){ this.title = curr.getAttribute('text'); } this.category_items.push({text: this.title}); } But, what I'd like to do is divide the list into categories. To do this, I'd need to append the text attribute value of the parent node to each of the child nodes under the parent node, and in the process, tell it to push the text attribute values of the childnodes if they exist, and of the parentnodes if they do not have childnodes. So I'd be left with something looking like: Code: Local News: Some local Blog1 Some local Blog2 National News: Some National Blog1 Some National Blog2 Misc: Community Classifieds Download More News I'd also like to be able to compare the value of an attribute such as "Download More News" and have that perform a specific function. Can somebody please point me to some information on grabbing only childnodes where they exist and also comparing the value of an attribute to a string? Thank you, Doc 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 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. 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 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 (); Ignore post (if mod, please delete)
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?? |