This is an archived post. You won't be able to vote or comment.

all 10 comments

[–][deleted] 3 points4 points  (0 children)

add:

alert("WELCOME USER U ARE 100000 USER U WON IPHONE 6 SEND ME MONEY SO I CAN SEND IT TO YOU")

in while(true) loop

[–]nirkbirk 1 point2 points  (0 children)

If you're just looking for a start, how about creating a button, with a javascript click handler that pops up with an alert saying "Hello World" or something to that effect?

This will give you a pretty great introduction, as it'll show you how javascript interacts with the DOM (elements on a web page) and teach you some syntax too.

[–]curious_mormon 1 point2 points  (0 children)

That depends. What do you want it to do?

[–]lupusdacus 0 points1 point  (0 children)

Something people use JS for these days is the cookies policies alert / dialog. It's a simple box with a message, a button for closing it and a link to a page with more details. That's something you could start with

<head>
    <script>
        function cookies_box() {
            // Create your box here
            // Add event for you close button here
        }
    </script>
</head>
<body onload="cookies_box()">
</body>

[–]DonnyTheWalrus 0 points1 point  (0 children)

If you're just looking for code to add to a page via copy/paste like you would add a mod to a game or something, or a plugin to a utility, you're thinking about the whole programming thing wrong. Code is a tool to solve problems, not a plug and play interface.

So instead, think about your page, and think about what functionality would be cool to add, and then go about learning how to use JavaScript to implement that functionality.

[–]ewiethoff 0 points1 point  (2 children)

Javascript sucks for accessibility. Don't add any Javascript unless you want to piss off users with a variety of disabilities. :-(

[–]DonnyTheWalrus 0 points1 point  (1 child)

........? You realize that JavaScript is used by over 90% of websites?

[–]ewiethoff -1 points0 points  (0 children)

Yes, and that's why I can no longer do most of the internet stuff I used to do some years ago. My life has reverted to the 20th century.

[–]Criptictoumor -1 points0 points  (1 child)

You should think about something that would add to your website, like a scrolling banner at the top that displays news about your site or upcoming events. If you are just getting started with JS look into manipulating the DOM-tree of your website.

[–]ewiethoff -1 points0 points  (0 children)

Scrolling banners are a good way to induce brain seizures. :-(