![]() |
So now you should have an idea what a variable is, and what a function is. A variable is a piece of data, and a function is code that you can pass arguments to in order to execute one or more actions. So that leads us to:
OBJECTS Let's say you wanted to write a program that simulates a car. You might define a few variables to set the parameters of the car, like so: Code:
var make = "Chevrolet"; Well, that's all fine and dandy, but what if you wanted your program to simulate two cars? Do you add the car name to the variables, and define an entirely separate set for the new car? Perhaps. But what if you want to simulate 100 cars? That would be a lot of variable naming. This is one useful application of programming Objects. An object is a variable which has it's own sub-set of variables and functions. I can define an object called Car, which contains all of the above variables and methods. Then, every instance of Car I create has it's own unique values for those variables, and when I run a function for one of the Car objects, the other Car objects are unaffected. A bit later we'll get into how to create custom objects, but Javascript does automatically create a bunch of objects automatically, such as the document object, which is created to allow you access to the webpage you're working with. To access an object's variables and functions, you provide the object variable, and then a period, and then the variable name of function name that you want. For example, with our fictional Car object: Code:
camaroSS.accelerate(); Code:
document.write("Some text"); Code:
alert(window.location); More later. |
I'm right with you. I have to read each line of your description 3 times, but it makes sense if I read slowly. I have a question, though. The very first characters of each code....are those commas, or periods?
it seems like they don;t matter. I did this without, and it works: this will be funnier for you if you don;t read the code first, but just paste it into the tester and run it.......but it still won;t be all that funny, so don;t get all excited var prompt = "Click OK if you understand this shit.\nClick Cancel if it's making your hair hurt."; if (confirm(prompt)) { document.write("yeah, bullshit, fonzie"); } else { alert("You're pretty dumb."); document.write("yup, pretty dumb"); } |
Quote:
|
Quote:
. var make = "Chevrolet"; var model = "Camaro SS"; var exteriorColor = "black"; var interiorColor = "charcoal"; var horsePower = "410"; . are these even part of the code, or are you just putting them there out of habit? |
What browser are you using? On mine, those are horizontal lines - not pat of the code at all.
|
-lumberjim
netscape 7.1 |
1 Attachment(s)
see?
|
Quote:
What are you doing running Nutscrape anyway? What kind of daft, running-around-with-limp-wrists silly person would choose Netscape over Mozilla? :D |
I've been through this with syc and UT. I LIKE netscape. Mozilla appears to just be askin to my netscape anyway, and it does not load IM, or my tabs. I have to tell it to show me navigator tabs, and it moves slower. I'll just ignore the dots.
browser snob |
Less chatting, more programming please.
|
Quote:
"Netscape is the short bus of web browsers!" "I'm not saying that anybody who uses Netscape is a dumb person, I'm just saying that even smart people are capable of doing dumb things." "Allow me to disabuse you of the notion that your browser of choice is in any way superior to a rotting heap of rhino feces!" I forget what the third step is, something about "intervention" or "hypertension" or "Star Trek convention." But we'll deal with that later. Programming... right. More to come soon. |
Well, things at work just got crazy, so there problably won't be anything new today. If I have time tonight I'll post something, though.
|
BUTTONS
hey, this is probably premature, but, how do you change the words on the buttons themselves?
does JS support that, or must you create a whole new code or object to be that prompt? oh, and can you crack the code in a browser or OS and make it change the word that displays on the normal buttons? ie. in stead of the button saying "OK" on it, it could say " Sure, why not" |
{(document.bgColor = "red");
(document.write("Coolness Quotient Test Site")); alert ("click OK to begin test"); document.write(" Results: You're a tool"); } how do you change the colors of the words? how do you clear the page to display the results? how do you change the location of the text on the page? |
Sorry about the delay, I'm currently being taken advantage of by my employer. I like working seven days a week for 12 hours per day.
I'll post more as soon as I am able. |
All times are GMT -5. The time now is 12:35 AM. |
Powered by: vBulletin Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.