Monday, 12 November 2012

HMTL 5, CSS3 and JavaScript for Windows 8 – Little JavaScript tips

In this post I am going to add these small things I always forget when I work with JavaScript and are quite useful:

How do you put a message in the browser’s status bar?: windows.status(“hello world”);

What do you use to comment in JavaScript?: // and /* */

What is the correct way to write a JavaScript array?: var txt = new Array (“Hello”,”World”, “how”);

How do you write something with JavaScript?: document.write(“Hello World”);

How does a “while” loop start?: while(i<=10);

What is the purpose of DOM (Document Object Model)?: The DOM represents the structure of a web page. You use it to add dynamic functionality to the page.

DOM core methods to create new objects for a document:

document.createElement(tagname)

document.createTextNode(string)

document.createAttribute(name,value)

document.createDocumentFragment

How do you round a number to the nearest integer?: Math.round(7.25);

How do you find the Maximum number between two numbers?: Math.max(x,y);

How to pass a JavaScript reference into a website: <script type=”text/javascript” src=”alertme.js”></script>

Internet Explorer 6,7 and 8 do not support addEventListener() and removeEventListener(). Use similar attachEvent() and detachEvent() functions instead.Some events in the HTML DOM ‘bubble’ meaning that if the event occurs on an element (and it is or isn’t handled), the event will then also fire on the element’s parent node and then on its grandparent node and so on until the event reaches an element where it may not bubble any further or it reaches the root node. Both addEventListener and removeEventListener have an optional third Boolean parameter indicating whether or not this is the case.

How do you find clients browser name?: navigator.appName

How do you open a new window in JavaScript?:mywindow=window.open(“http://www.google.com”);

How do you split a large string in two lines in Javascript?: document.write(“hello my name is \prince”);

Microsoft implementation of JavaScript is called JScript.

<noscript> tag Alerts the users that your page uses JavaScript, and so the user should enable JavaScript in the browser in order to display your page correctly.

Having the following code what does this code returns….(this is a nice exercise):

About Me

I am a dedicated software developer who has been programming since I was 9 years old, when I made my first game in an Amstrad 128kb... after 25 years I keep doing the same stuff with different systems... If you have any problems or you want to contribute to this blog please email me to gabrielrenom@gmail.com

I have been Developing applications for mobile devices since late 90's I am keep dedicated to mobile development working with iPhone, iPad, iTouch , Windows Mobile and Android platforms having my own column in the US magazine i.Business. www.ibusinessmag.com.
Currently working in the legal industry for DWF LLP.