/    Sign up×
Community /Pin to ProfileBookmark

General Javascript Question

Hi,

I’m very new to Javascript and had a general question. I know that in javascript you have certain functions like getElementByTag or getElementByID to modify html pages and you can add links to an html page, align text and so on. My question is, what is the advantage of indirectly modifying an html page through javascript when you can modify the html directly without using any javascript?

Thank you!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@celestineMar 12.2014 — Heeheheheh.....

That's a good question i am not known about java but i used to do html of several sites and i use javascript in it...

But you question blow my mind..
Copy linkTweet thisAlerts:
@JMRKERMar 12.2014 — If your page is static and does not normally change anything, then there is no advantage to using JS.

If you want a page to animate, update, pre-submit validation, etc, then you would be hard pressed to do it without JS.

Really depends upon your needs.


Are there other programming languages that might accomplish your requirements, yes, but not many so easy to incorporate.
Copy linkTweet thisAlerts:
@AJ217authorMar 12.2014 — Do you mean if you want the page to update on its own? Can you give me some more examples? Thank you.
Copy linkTweet thisAlerts:
@Sup3rkirbyMar 12.2014 — Well, with things like 'getElementById()' and so on, it's not only about modifying the content, but also making your pages dynamic and more interactive. This goes from simply giving a user something nice to look at on a page to full video games right in the browser window. Anytime something on a page moves, interacts with a user (aside from a standard input) or changes, you will find javascript behind it (for the most part).

In terms of content, it's possible to help present data on your page in a more controlled and user-friendly manor, such as hiding certain bits of a page until a user needs to see them (perhaps they are filling out a form, you can break it in to sections or steps then hide and display each step as the user needs, all on one page). Also through the use of AJAX you can actually load entirely new page content without having to leave the page, which is good for standard content as well as dynamic content (requesting reporting data, simple chat/messaging, sending/receiving file data (somewhat limited on the upload)).

And let's not forget about analytics data. With javascript you can keep track of how users interact with your page and how long they stay on a page. There are tons of metrics to gather about users on your website and javascript makes it easier to get that data (and save it on some server somewhere).

Javascript is capable of some very amazing things, and the list continues to grow as browsers and computers become more powerful and complex.
×

Success!

Help @AJ217 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...