Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Daniel Leavey

Dom Methods

Recommended Posts

I've noticed that the book doesn't include any discussion of the innerHTML DOM method. Is there a reason for its exclusion, or has the method been replaced some more modern technique?

 

Thank you.

Share this post


Link to post
Share on other sites

innerHTML is not part of the official DOM standard, but it was included by Microsoft in IE, and was so popular that all browsers support it now. Also, innerHTML is not a method, but a property.

  • Upvote 1

Share this post


Link to post
Share on other sites

I have to say, I've found learning JavaScript one of the hardest tasks in building my web design/development skills. Some of the books are riddled with coding errors, and some have no errata page online. Others, like the one I was reading prior to  Larry Ullman's book, referred to the"innerHTML DOM method". In any case, I am still not clear as to why "innerHTML" was not covered in Mr. Ullman's book. 

Share this post


Link to post
Share on other sites

There you go. Thanks, Edward. I didn't know that innerText and innerHTML were interchangeable. I really do have to put aside Tim Wright's "Learning Javascript." It has befuddled my mind. Pollocks 3rd edition (now ancient) did a lot more to introduce me to JavaScript, and I'm hoping Larry's book will help me to make the real-world connection to interactivity. 

 

I think this forum is also going to be very, very helpful.

  • Upvote 1

Share this post


Link to post
Share on other sites

Yes, my biggest complaint about JS is that it's quite possibly the most important language to the web right now, and there's not a single reliable go-to resource for it.

Also, innerHTML and innerText are not the same, as demonstrated by the following quick script:

 

<!DOCTYPE html>
 
<html lang="en">
  
  <head>
    
    <title>innerHTML vs. innerText</title>
    
    <meta charset="UTF-8">
    
  </head>
  
  <body>
    
    <div id="the_div">
      
      <p>Hello world!</p>
      
      <ul>
        
        <li>Item 1</li>
        
        <li>Item 2</li>
        
      </ul>
      
    </div>
    
    <script>
      
      alert(document.getElementById('the_div').innerHTML);
      
      alert(document.getElementById('the_div').innerText);
      
    </script>
    
  </body>
  
</html>
  • Upvote 1

Share this post


Link to post
Share on other sites

 

Yes, my biggest complaint about JS is that it's quite possibly the most important language to the web right now, and there's not a single reliable go-to resource for it.

  

Hey HartleySan,

 

I'm no expert - just a novice as you know but i do read forums all over the place with conflicting views. Just wondered what your thoughts might be if the questions aren't too bothersome:

 

Would you rank javascript even higher than PHP (for importance)?

 

I am about half way through the PHP/MySQL Book and I am focusing on PHP now.

I bought Modern Javascript already which I will eventually read and I know javascript is important.

But I am thinking of getting the OOP PHP book first because lots of discussions seem to point to the importance of knowing about OOP and I'm kinda getting into the swing of things with PHP.

 

Furthermore, have you any thoughts about where DART might go?

Share this post


Link to post
Share on other sites

StephenM, good questions. I can't predict the future, but here are my thoughts:

 

It's hard for me to say whether PHP is more important than JS or vice versa, but I will say this: With a mastery of PHP/MySQL and JS, you can do pretty much anything on the web. And in the rare cases where you can't do something with those languages, your knowledge of those languages will be more than enough to quickly pick up whatever language is required to do what you want to do.

 

If I had to pick between PHP and JS though, I'd probably go with PHP only because PHP allows you to do 99% of the things you want/need for web pages. Certainly, JS has that cool factor to it, and some of the new APIs in JS allow you to do things that no other languages can do on the web, but in how many cases do you really need the functionality that things like WebGL and WebRTC in JS have to offer? Again, they're cool, and as time goes on, I think their usefulness will increase, but for the time being 99.9% of the sites out there really only require static pages with secure forms and DB access. PHP can do all of that. JS can do none of that (or if it can, PHP can do it better).

 

Now, with all that said, I think that any decent web developer these days must have good working knowledge of JS and at least one server-side language (with my obvious preference being PHP). As such, I don't think that it matters whether JS is more important than PHP/MySQL or not, because you need both (and also good knowledge of HTML and CSS) to really make good web pages and applications anyway.

 

As such, I highly recommend sticking with the PHP/MySQL book till the end, and ensuring that you understand most to everything in it. After that, I would move on to the JS book.

 

As for Dart, well, who knows. I don't think that Dart will live on forever in its current form, but I do think it'll become the base or at least greatly influence the successor to JS. I do believe that JS is the fastest growing and most important language for the future of the web, but it needs to change a lot beyond what it is capable of now to really become what it needs to be.

 

The changes required of JS may come either through an upgrade to JS, or as a separate language that replaces JS. Either way, I think most people familiar with JS know what its shortcomings are and how it needs to change to become better. Whether that happens through a JS upgrade or a separate language is kind of irrelevant, because the end result will likely be the same. To that end, I think Dart is good, because it's helping push JS in the right direction and it gets people talking.

Share this post


Link to post
Share on other sites

Your opinion mirrors a lot of what I already thought.

I'm definitely sticking with the MySQL/PHP book to the end. I'm very happy with the book so far.

I'll have to toss a coin then to see which to move onto next! I don't think it matters too much as I plan to read both, eventually.

Interesting insights there on the future of Javascript. One thing that confuses a beginner is the lack of

harmonization --> dozens of different frameworks each with their niche. It's a bit flabbergasting.

What I would take from this is in terms of time invested perhaps a PHP:JS ratio of 2:1 sounds about right.

What I try to do in general is every now and again step away from the PHP and do a bit of HTML/CSS because

1. It is like a breath of fresh air sometimes. 2. I can continue an underlying level of HTML/CSS

One thing is for sure, choosing the right tools to invest time in is also important.

Thanks a lot for the extended answer.

Share this post


Link to post
Share on other sites

Yeah, I know what you mean. All the JS frameworks out there is a bit overwhelming (which is why I rarely use any of them). In fact, unless a client asks me to use a JS framework/library, I never do. That's not to say that they're bad, but why would I include a 90k library file, when I can easily code the same cross-browser solution they use for finding the height of the viewport, etc. Nowadays, just about everything you want to know about JS is on Stack Overflow.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...