Tuesday , 16 July 2019
Home / Tag Archives: JavaScript (page 3)

Tag Archives: JavaScript

Device Events – Advanced JavaScript Tutorial

Device Events

Smartphones and tablets are devices that are frequently used to browse websites. JavaScript now has a couple of events for hand held devices.  For this tutorial, you’ll need to have a mobile phone. I’ll be using the Iphone for this tutorial. Feel free to skip this tutorial if you don’t have a device handy. Orientation The orientationchange event fires when …

Read More »

Keyboard Events – Advanced JavaScript Tutorial

Keyboard Events

It’s time to take a look at keyboard events. Another popular feature of JavaScript is the capability to detect which keys were pressed and how they were pressed. Let’s first update our document to this. [crayon-5d2d1d20a7628946095379/] Sweet! Now, let’s clear up the script and add this bit of code. [crayon-5d2d1d20a7637011112754/] The first kind of event is the keydown event. This …

Read More »

Mouse Events – Advanced JavaScript Tutorial

Mouse Events

Keep track of how the mouse interacts with the web page. It is the primary device for navigation after all. Whenever mouse events occur, you’re passed in a lot of information as to where the mouse is located or what is also happening with the mouse. Let’s take a look at how this works. Coordinates We’re going to keep our …

Read More »

UI Events – Advanced JavaScript Tutorial

UI Events

UI events are events that aren’t specific to the document, but the window object. These events fire when something happens to the browser or window. Loading Events Loading events fire when the window has loaded all scripts, images, files and styles. There are also unloading events for when the user leaves the page. Update your document to this. [crayon-5d2d1d20a8584256846459/] Let’s …

Read More »

Event Object – Advanced JavaScript Tutorial

Event Object

The event object is passed into your function whenever an event occurs. This object contains information about the event and even allows you to change how the event phases flow. We’ll be working with our previous example. Update your script to this. [crayon-5d2d1d20a8d2c701152923/] Our functions have been updated so that we can reference the event object. The event parameter will …

Read More »

Event Handlers – Advanced JavaScript Tutorial

Event Handlers

If you’ve seen my events tutorial in my JavaScript basics tutorial series, then you already know how to use events. There’s another way of using events with event handlers. Before we begin, let’s update the <body> tags in our document to this. [crayon-5d2d1d20a94f1367995137/] We just have a simple button in our document with the ID btn. To add an event, …

Read More »

Data Attribute – Advanced JavaScript Tutorial

Data Attribute

HTML5 is fairly new and it’s slowly being adopted by all web browsers today. A special feature of HTML5 is the ability to define custom data attributes. A data attribute is your own attribute that can contain information about an element. Let’s update our document to this. [crayon-5d2d1d20a9d75617680830/] To create a data attribute, you simply create an attribute with the …

Read More »

Navigator Object – Advanced JavaScript Tutorial

Navigator Object

The navigator object allows you to grab information about the browser and visitor’s computer. You can grab the browser name, plugins, OS, language, etc. Properties Clear your script and add this bit of code. [crayon-5d2d1d20aa296254177059/] The navigator object is pretty tricky. Even though the navigator object has been around since Netscape Navigator 2, the properties and methods are supported in …

Read More »

Location Object – Advanced JavaScript Tutorial

Location Object

The location object contains information about the current URL you’re visiting. It can give you helpful information such as the port number, whether or not the site is using SSL and even allows you to redirect the user. Properties Clear your script and add this bit of code. [crayon-5d2d1d20aa7e2795722549/] There are a couple of properties of the location object, but …

Read More »

Timing Events – Advanced JavaScript Tutorial

Timing Events

There are 2 kinds of timing events. There’s one with timeouts and another with intervals. Timeouts execute once after a certain amount of time has passed by. Intervals execute repeatedly after a certain amount of time has passed by. Timeouts Clear your script and add this bit of code. [crayon-5d2d1d20aae17419975477/] To create a timeout you use the setTimeout() method. This …

Read More »