SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A few burning questions about basic JavaScript

    What is the purpose of a JavaScript library and what does it do?

    I presume it would be another js file that ensures the script loads after the html, I also think it's where objects are defined and referenced. Am I way off?

    I was having trouble with this because I think some of the naming conventions are different for different objects between different libraries and it just adds more complexity to the language, couldn't I just create objects with names that make sense to me?


    Can you use JavaScript to change CSS styles that are still functional/use-able with JavaScript disabled? In other words, can you swap the way the page is presented based on browser settings?

  2. #2
    SitePoint Guru
    Join Date
    Oct 2006
    Location
    Queensland, Australia
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sounds like you're failing to understand even the basic concepts of not just javascript, but scripting languages in general. I recommended searching online for some javascript introductory tutorials, or even better, find yourself a good book.

    Javascript strangely enough was the first experience I'd with a scripting/programming, yet it's one of the last things I'm yet to fully learn. I just lost interest with it early on.

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,338
    Mentioned
    465 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by JaneSays View Post
    What is the purpose of a JavaScript library and what does it do?
    A library is basically a collection of functions and objects collected into one or more files. Each library has its own syntax for referencing those functions etc. I'm still learning JavaScript (I only started recently) but personally, I would rather learn how JS works than learn how to use a particular library, which seems just about as much work to me!

    I presume it would be another js file that ensures the script loads after the html
    Certainly they would cater for that.

    Can you use JavaScript to change CSS styles that are still functional/use-able with JavaScript disabled? In other words, can you swap the way the page is presented based on browser settings?
    Yes.

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Web browsers have subtle bugs and differences between them that makes coding a real pain sometimes(assuming you want your code to work reasonably well across a wide range of browsers - you should!). A library contains code which unifies many of these differences, so it can make it far easier on the programmer because you don't need to be constantly writing workarounds and different code for different browsers. Learning/discovering the differences and bugs is a huge undertaking that really shouldn't be necessary, but its the reality.

    A lib also tends to make it just plain easier and faster to do many of the things people commonly use javascript for. For example, finding all divs with a certain class name and making them do something when you hover over them. With a library, this will probably be just a few lines of code. With native javascript, it could be 10-30.

    But, I recommend you don't start with a library if your goal is to learn js. Once you learn js to maybe an intermediate level, then think about turning to a library. You'll be able to understand what's going on much better. Otherwise you'll probably be lost and require large amounts of hand holding.

  5. #5
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Can you use JavaScript to change CSS styles that are still functional/use-able with JavaScript disabled? In other words, can you swap the way the page is presented based on browser settings?
    I may be reading this differently to Ralph, but I would say no. You're asking if you can use JavaScript to do something when JavaScript is disabled. It's like asking if you can ride a bicycle without a bicycle.

  6. #6
    SitePoint Guru
    Join Date
    Oct 2006
    Location
    Queensland, Australia
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raffles View Post
    It's like asking if you can ride a bicycle without a bicycle.
    I've seen it done!

  7. #7
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your answers!

    I have actually finally found a good JavaScript book after having read two duds. These questions came up after chapter 2. The book I'm reading is a sitepoint publication and is called "Simply JavaScript" by Kevin Yank and Cameron Adams.

    I really appreciate how the book starts out with programming logic. Since I have taken a programming logic class I am hopeful that JavaScript will put some of the basic flowcharts models I've constructed in my mind visually into real action.

    For the JavaScript/CSS question, I meant that a person should technically build there CSS so that it looks presentable without JavaScript enabled. Then when JavaScript is enabled that CSS can be altered in appearance. I think I might find the answer to this in chapter three of Simply JavaScript.

  8. #8
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Wardrop View Post
    I've seen it done!
    Don't tell me... by a cat?

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,338
    Mentioned
    465 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by JaneSays View Post
    For the JavaScript/CSS question, I meant that a person should technically build there CSS so that it looks presentable without JavaScript enabled. Then when JavaScript is enabled that CSS can be altered in appearance. I think I might find the answer to this in chapter three of Simply JavaScript.
    Yeah, that's what I thought you meant, which is why I said yes. Always make sure the site will work nicely without JS (and without CSS, for that matter), and then add the JS as an enhancement.

  10. #10
    SitePoint Wizard Blake Tallos's Avatar
    Join Date
    Jun 2008
    Location
    Cuyahoga Falls, Ohio.
    Posts
    1,511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JaneSays View Post
    Thank you for your answers!

    I have actually finally found a good JavaScript book after having read two duds. These questions came up after chapter 2. The book I'm reading is a sitepoint publication and is called "Simply JavaScript" by Kevin Yank and Cameron Adams.

    I really appreciate how the book starts out with programming logic. Since I have taken a programming logic class I am hopeful that JavaScript will put some of the basic flowcharts models I've constructed in my mind visually into real action.

    For the JavaScript/CSS question, I meant that a person should technically build there CSS so that it looks presentable without JavaScript enabled. Then when JavaScript is enabled that CSS can be altered in appearance. I think I might find the answer to this in chapter three of Simply JavaScript.
    Correct! Javascript should be the last option for you to fully optimize your website. Build it's fundamentals and apply Javascript to your site afterwards.
    Blake Tallos - Software Engineer for Sanctuary
    Software Studio, Inc. C# - Fanatic!
    http://www.sancsoft.com/


  11. #11
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Raffles View Post
    I may be reading this differently to Ralph, but I would say no. You're asking if you can use JavaScript to do something when JavaScript is disabled. It's like asking if you can ride a bicycle without a bicycle.
    The way I first read that I thought as you did that it was asking if you can change the styles using JavaScript when javaScript is disabled.

    It is in fact asking if you can have styles that are functional/usable without JavaScript and change them using JavaScript. So the answer is in fact yes.


    You do it the same way you use JavaScript to test whether javaScript is disabled - by having the HTML and CSS the way it needs to be for when javaScript is disabled and then using JavaScript to modify the HTML and CSS when it is available.

    The simplest example would be:

    Code:
    <p>JavaScript is <b id="script">not </b>enabled.<p>
    <script type="text/javascript">
    document.getElementById('script').style.display = 'none';
    </script>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  12. #12
    SitePoint Enthusiast scout1idf's Avatar
    Join Date
    Nov 2009
    Location
    Ohio
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JaneSays View Post
    Thank you for your answers!

    I have actually finally found a good JavaScript book after having read two duds. These questions came up after chapter 2. The book I'm reading is a sitepoint publication and is called "Simply JavaScript" by Kevin Yank and Cameron Adams........
    I just finished reading "JavaScript A Beginners Guide 2nd edition" by John Pollock. Even though I am just beginning and don't understand much, I found it informative. I like how each chapter gives you a test at the end and some Q&A spots through out the chapters.

    I had to laugh in the beginning where he says, "You remember algebra from school......."

    I didn't take algebra.

  13. #13
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by scout1idf View Post
    I just finished reading "JavaScript A Beginners Guide 2nd edition" by John Pollock. Even though I am just beginning and don't understand much, I found it informative. I like how each chapter gives you a test at the end and some Q&A spots through out the chapters.

    I had to laugh in the beginning where he says, "You remember algebra from school......."


    I didn't take algebra.
    I didn't take algebra in college either! I took Philosophy - LOGIC 112.

    I went to college for Graphic Design, I work as a Web Designer-1st year, need a better job but it's been rough, I started a web programming degree, then I estimated future student loan debt, and dropped out. now here I sit thinking if I just new how to do JavaScript I could get out of this town and on with my life. Finding resources that don't teach you how to do it the wrong way is pretty important.

    I will definitely check out that book.

    Books I WOULD NOT recommend for a beginner:
    "Head First JavaScript A Brain Friendly Guide"
    by Michael Morrison
    "Visual Quickstart Guide JavaScript and AJAX Seventh Edition"
    by Tom Negrino and Dori Smith

    The first was the lesser of the two evil for the beginner because it has a ton of content, puzzles, projects, and files. It does move outside of the alert() function and into other things I will admit I haven't tried yet.

    If you have a true interest in programming and want to understand what "math" if any is behind it check out this one:

    "Programming Logic and Design Fifth Edition" by Joyce Farrell. The only trouble I had with it was that I'm on a mac OS so the Microsoft Visio trial didn't work for me, but I just used Concept Draw instead.

    I'm beginning to think that JavaScript wasn't the ideal first programming language to learn. I'm still a bit fuzzy about JS libraries like JQuery and how they work in tune with the JS files for a particular function. I wish there were some diagram that went through everything step by step.

    I also have been listening to the lectures of Dr Tony Pittarese. He really breaks it down. I'm going to try to find videos or files for his course.

    Another good resource/ site I'm learning from is net Tuts...

    I can't post links yet apparently but there are a bunch of vids put together called- 17 Hours of JavaScript from the masters.

  14. #14
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,122
    Mentioned
    29 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by JaneSays View Post
    I have actually finally found a good JavaScript book after having read two duds. These questions came up after chapter 2. The book I'm reading is a sitepoint publication and is called "Simply JavaScript" by Kevin Yank and Cameron Adams.
    Simply Javascript is excellent. It gives the best introduction to javascript of any book I have come across. Good choice.

  15. #15
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by scout1idf View Post
    I had to laugh in the beginning where he says, "You remember algebra from school......."

    I didn't take algebra.
    I thought that Algebra was one of the basic areas of Mathematics that everyone was expected to know BEFORE starting high school. Something taught long before you start to get to choose what subjects you are going to study. About the only way of not having been taught Algebra would be if you left school before you were nine years old. At least that's the case in the several countries where I have some knowledge of how their education system works. Just about anything in mathematics beyond knowing your times tables requires a knowledge of Algebra and everything involving programming is heavily dependent on it.

    To not study Algebra when you are nine or ten years old would put you at a real disadvantage when it comes to anything involving computers or money.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  16. #16
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    To not study Algebra when you are nine or ten years old would put you at a real disadvantage when it comes to anything involving computers or money.

    I think we are talking about College Algebra which is usually required if you are looking for a degree in computer programming. I was never great at Algebra in high school. It was seriously as if I had some type of deprivation preventing me from fully understanding what Algebra was all about. I took a few philosophy classes in college and found all the fundamentals I had been missing during those years of teachers trying to beat equations into me as if somehow it would start to make sense if I just absent mindedly repeated the steps over and over again. If you are having trouble with Algebra I'd suggest sitting down with Wittgenstein's Philosophical investigations, you will be so perplexed that suddenly core concepts like triangulation make sense in a way you never thought possible. If you want more check out some symbolic logic. The next time you open an Algebra book it will make more sense than it ever has before.

    Whatever you do don't let anyone tell you you can't do something.

  17. #17
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,338
    Mentioned
    465 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by JaneSays
    Books I WOULD NOT recommend for a beginner:...

    "Visual Quickstart Guide JavaScript and AJAX Seventh Edition"
    by Tom Negrino and Dori Smith
    Yeah, I tried that one and it's really hard to follow.

    I've just read Jeremy Keith's DOM Scripting book and it's a superb introduction to JS. One of the best beginner books I've ever read. He's a brilliant teacher.

    Quote Originally Posted by felgall
    I thought that Algebra was one of the basic areas of Mathematics that everyone was expected to know BEFORE starting high school.
    Yeah, I used to teach it to 7 and 8-year-olds and they loved it. Start them young, I say.

  18. #18
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found another GOOD learning JavaScript resource:

    Search iTunes store for Dr. Tony Pittarese. Download all 9 tracks of Advanced topics in Web Development for free. Click the syllabus and the slides link and you can download the lecture notes and JavaScript files to follow as he teaches the course.

  19. #19
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,338
    Mentioned
    465 Post(s)
    Tagged
    8 Thread(s)
    Thanks Jane. I've been meaning to check out such stuff on iTunes. Now I have a reason.

  20. #20
    SitePoint Enthusiast scout1idf's Avatar
    Join Date
    Nov 2009
    Location
    Ohio
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    I thought that Algebra was one of the basic areas of Mathematics that everyone was expected to know BEFORE starting high school. Something taught long before you start to get to choose what subjects you are going to study. About the only way of not having been taught Algebra would be if you left school before you were nine years old. At least that's the case in the several countries where I have some knowledge of how their education system works. Just about anything in mathematics beyond knowing your times tables requires a knowledge of Algebra and everything involving programming is heavily dependent on it.

    To not study Algebra when you are nine or ten years old would put you at a real disadvantage when it comes to anything involving computers or money.
    I graduated in 1986 (from High School) and went into the Army. I never went to college. I work in a factory and finally got a computer and the internet only 2 1/2 years ago, though I've used a computer in my job (limited) for years.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •