Jump to content

Search the Community

Showing results for tags 'property'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 5 results

  1. Hi, Is it possible to access property of the object using variable, for example I have the object named "objExample" with properties named: Property1 Property2 Property3 Property4 ... Property10 I would like to access all of these properties in FOR loop using variable propertyName = " Property " & i in each step, but I don't know how to make it. The code below it's an simple example of my problem ("???" indicates piece of code which I missing): Dim i Dim propertyName Dim objExample Set objExample = ....... For i = 1 To 10 propertyName = " Property " & i objExample.??? = ...... ...... Next Best regards
  2. Good afternoon Can someone explain to me the difference between these properties, please? As for me are one and the same. Regards: Marek
  3. <!DOCTYPE html><html><head><script>function myFunction(e){ alert(e.target);}</script></head><body onclick="myFunction(event)"><p>Click on a paragraph. An alert box will alert the element that triggered the event.</p><p><strong>Note:</strong> The target property returns the element that triggered the event, and not necessarily the eventlistener's element.</p></body></html> Hi guys, I am really struggling with this right now, please help. As you can see the above, I don't really understand these lines of code <body onclick="myFunction(event)">, and function myFunction(e) {alert(e.target);} what do "event" and "e" do, I know they are parameters which I can use whatever I like, my question is, why do I need "event" and "e" parameters here, and why are they so important? Second question, this line <body onclick="myFunction(event)">, I don't really know what the difference between <body onclick="myFunction(event)"> and <body onclick = myFunction>(without parenthesis and quotes). Thanks a bunch guys.
  4. I’m working my way through Javascript Step by Step (Steve Suehring, Microsoft Press) and I’m having difficulty understanding the way the words ‘object’ and ‘property’ are used in the book. In this post I will put verbatim extracts from the book in blue. Things start off simply enough: You can create an object in Javascript in two ways: * Using the new keyword, as shown here: var star = now Object; * Using curly braces, as shown here: var star = {}; The author explains there is no concept of classes in Javascript, but shows how to create objects using pseudo-class constructors: var star = {}; function Star(constell,type,specclass,magnitude) { this.constellation = constell; this.type = type; this.spectralClass = specclass; this.mag = magnitude;} star["Polaris"] = new Star("Ursa Minor","Double/Cepheid","F7",2.0);star["Mizar"] = new Star("Ursa Major","Spectroscopic Binary","A1 V",2.3);star["Aldebaran"] = new Star("Taurus","Irregular Variable","K5 III",0.85);star["Rigel"] = new Star("Orion","Supergiant with Companion","B8 Ia",0.12);star["Castor"] = new Star("Gemini","Multiple/Spectroscopic","A1 V",1.58);star["Albireo"] = new Star("Cygnus","Double","K3 II",3.1);star["Acrux"] = new Star("Crux","Double","B1 IV",0.8);star["Gemma"] = new Star("Corona Borealis","Eclipsing Binary","A0 V",2.23);star["Procyon"] = new Star("Canis Minor","Double","F5 IV",0.38);star["Sirius"] = new Star("Canis Major","Double","A1 V",-1.46);star["Rigil Kentaurus"] = new Star("Centaurus","Double","G2 V",-0.01);star["Deneb"] = new Star("Cygnus","Supergiant","A2 Ia",1.25);star["Vega"] = new Star("Lyra","White Dwarf","A0 V",0.03);star["Altair"] = new Star("Aquila","White Dwarf","A7 V",0.77); The heading he puts on this section is Assembling a star object using a pseudo-class. Note he uses the singular. He doesn’t say ‘Assembling star objects’. The next section is headed Displaying Object Properties and has the following code and explanation: With a for…in loop, you can loop through each of the properties in an object: DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Properties</title> <script type="text/javascript"> var star = {}; function Star(constell,type,specclass,magnitude) { this.constellation = constell; this.type = type; this.spectralClass = specclass; this.mag = magnitude; } star["Polaris"] = new Star("Ursa Minor","Double/Cepheid","F7",2.0); star["Mizar"] = new Star("Ursa Major","Spectroscopic Binary","A1 V",2.3); star["Aldebaran"] = new Star("Taurus","Irregular Variable","K5 III",0.85); star["Rigel"] = new Star("Orion","Supergiant with Companion","B8 Ia",0.12); star["Castor"] = new Star("Gemini","Multiple/Spectroscopic","A1 V",1.58); star["Albireo"] = new Star("Cygnus","Double","K3 II",3.1); star["Acrux"] = new Star("Crux","Double","B1 IV",0.8); star["Gemma"] = new Star("Corona Borealis","Eclipsing Binary","A0 V",2.23); star["Procyon"] = new Star("Canis Minor","Double","F5 IV",0.38); star["Sirius"] = new Star("Canis Major","Double","A1 V",-1.46); star["Rigil Kentaurus"] = new Star("Centaurus","Double","G2 V",-0.01); star["Deneb"] = new Star("Cygnus","Supergiant","A2 Ia",1.25); star["Vega"] = new Star("Lyra","White Dwarf","A0 V",0.03); star["Altair"] = new Star("Aquila","White Dwarf","A7 V",0.77); </script></head><body><script type="text/javascript" > for (var propt in star) { alert(propt); } </script></body></html> View this page in a web browser. You are presented with an alert() dialogue box for each of the stars in the star object, for a total of 14. Here’s an example of the type of dialog box you see: (displays alert box with 'Polaris', followed by 13 more alerts, Mizar through to Altair) This step-by-step builds on the earlier example of using pseudo-classes to define properties of objects. In this case, a star object was created with the following code: var star = {}; That object was then given several properties of individual star names by using a call to create a new Star [sic] object (using the pseudo-class): star["Polaris"] = new Star("Ursa Minor","Double/Cepheid","F7",2.0); Each property of the original star object, in this case the name of each star, was then enumerated within the <body> of the code using a for…in loop: for (var propt in star) { alert(propt); } You might be wondering how to get the actual properties of the stars, such as the constellations, magnitudes, types and spectral class. Chapter 14 shows you how to enumerate through each of these. The bits in bold are what trouble me. Here are my questions: 1. When the block of code above is run, how many objects are created in total? 1, 14 or 15? 2. Would it be right or wrong to call the result a collection of objects (in the sense of a Visual Basic collection)? 3. Is the word preceding my [sic] mark a typo for star, seeing that Star is the name of a function, not an object? 4. When the author refers to the named properties of star (constell, type, specclass, magnitude) as it’s ‘actual properties’ (his last para), is he implying that the star name (e.g. Polaris) is not a true property? Hope someone can clear this up so I can get on to the next chapter!
  5. <!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=utf-8" /><title>Untitled Document</title><script>var left;function setStyle(element,property){ if(window.getComputedStyle){ left = window.getComputedStyle(element,null).getPropertyValue(property); } else { left = element.currentStyle.property; }}function getStyle(){document.getElementById("show").innerHTML = left;}function init(){setStyle(document.getElementById("div"),"left");getStyle();}</script><style>#div {background-color: red;position: absolute;left: 100px;top: 100px;width: 100px;height: 200px;}</style></head><body onload="init()"><div id="div"></div><div id="show"></div></body></html> My problem is why this script doesn't work, when I want to pass the property "left"? function setStyle(element,property){ if(window.getComputedStyle){ left = window.getComputedStyle(element,null).property; } else { left = element.currentStyle.property; }} function getStyle(){document.getElementById("show").innerHTML = left;}function init(){setStyle(document.getElementById("div"),left);getStyle();}
×