![]() |
|
Technology Computing, programming, science, electronics, telecommunications, etc. |
![]() |
|
Thread Tools | Display Modes |
![]() |
#16 |
I am meaty
Join Date: Dec 2001
Location: Salt Lake City, UT
Posts: 1,119
|
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"; var model = "Camaro SS"; var exteriorColor = "black"; var interiorColor = "charcoal"; var horsePower = "410"; 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(); mustangGT.accelerate(); alert("Who's your daddy?"); Code:
document.write("Some text"); Code:
alert(window.location); More later.
__________________
Hot Pastrami! |
![]() |
![]() |
![]() |
#17 |
I can hear my ears
Join Date: Oct 2003
Posts: 25,571
|
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"); }
__________________
This body holding me reminds me of my own mortality Embrace this moment, remember We are eternal, all this pain is an illusion ~MJKeenan |
![]() |
![]() |
![]() |
#18 | |
I am meaty
Join Date: Dec 2001
Location: Salt Lake City, UT
Posts: 1,119
|
Quote:
__________________
Hot Pastrami! |
|
![]() |
![]() |
![]() |
#19 | |
I can hear my ears
Join Date: Oct 2003
Posts: 25,571
|
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?
__________________
This body holding me reminds me of my own mortality Embrace this moment, remember We are eternal, all this pain is an illusion ~MJKeenan |
|
![]() |
![]() |
![]() |
#20 |
I think this line's mostly filler.
Join Date: Jan 2003
Location: DC
Posts: 13,575
|
What browser are you using? On mine, those are horizontal lines - not pat of the code at all.
__________________
_________________ |...............| We live in the nick of times. | Len 17, Wid 3 | |_______________| [pics] |
![]() |
![]() |
![]() |
#21 |
Come on, cat.
Join Date: Nov 2003
Location: general vicinity of Philadelphia area
Posts: 7,013
|
-lumberjim
netscape 7.1
__________________
Crying won't help you, praying won't do you no good. |
![]() |
![]() |
![]() |
#22 |
Come on, cat.
Join Date: Nov 2003
Location: general vicinity of Philadelphia area
Posts: 7,013
|
see?
__________________
Crying won't help you, praying won't do you no good. |
![]() |
![]() |
![]() |
#23 | |
I am meaty
Join Date: Dec 2001
Location: Salt Lake City, UT
Posts: 1,119
|
Quote:
What are you doing running Nutscrape anyway? What kind of daft, running-around-with-limp-wrists silly person would choose Netscape over Mozilla? ![]()
__________________
Hot Pastrami! |
|
![]() |
![]() |
![]() |
#24 |
I can hear my ears
Join Date: Oct 2003
Posts: 25,571
|
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
__________________
This body holding me reminds me of my own mortality Embrace this moment, remember We are eternal, all this pain is an illusion ~MJKeenan |
![]() |
![]() |
![]() |
#25 |
Constitutional Scholar
Join Date: Dec 2002
Location: Ocala, FL
Posts: 4,006
|
Less chatting, more programming please.
__________________
"I'm completely in favor of the separation of Church and State. My idea is that these two institutions screw us up enough on their own, so both of them together is certain death." - George Carlin |
![]() |
![]() |
![]() |
#26 | |
I am meaty
Join Date: Dec 2001
Location: Salt Lake City, UT
Posts: 1,119
|
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.
__________________
Hot Pastrami! |
|
![]() |
![]() |
![]() |
#27 |
I am meaty
Join Date: Dec 2001
Location: Salt Lake City, UT
Posts: 1,119
|
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.
__________________
Hot Pastrami! |
![]() |
![]() |
![]() |
#28 |
I can hear my ears
Join Date: Oct 2003
Posts: 25,571
|
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"
__________________
This body holding me reminds me of my own mortality Embrace this moment, remember We are eternal, all this pain is an illusion ~MJKeenan Last edited by lumberjim; 03-24-2004 at 07:50 PM. |
![]() |
![]() |
![]() |
#29 |
I can hear my ears
Join Date: Oct 2003
Posts: 25,571
|
{(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?
__________________
This body holding me reminds me of my own mortality Embrace this moment, remember We are eternal, all this pain is an illusion ~MJKeenan |
![]() |
![]() |
![]() |
#30 |
I am meaty
Join Date: Dec 2001
Location: Salt Lake City, UT
Posts: 1,119
|
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.
__________________
Hot Pastrami! |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|