Posts Tagged ‘Javascript’
26
Jan
Ext.apply is a Sencha function to copy objects.
Ext.apply(, );

You can have multiple source object names separated by comma.

Why do we need Ext.apply? Isn’t = enough? No, its not. Not only because you can merge and copy multiple sources to the destination there is also the big reason that, just a simple ‘=’ copies only the reference of the source object to the destination. Which means that if, you make any change to the destination object after copy it will affect the source copy too!

, , , , ,

05
Aug

You can format numbers in javascript in following way:

var num = 12;

var dec = 2; // decimal part rounded to 2var fomatedNumber = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
alert(fomatedNumber) ;

num = 45.6739;

var fomatedNumber = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);

alert(fomatedNumber) ;

That’s it.

, , , , ,

26
May

In-order to detect an orientation change on an Android browser, add a listener for either the ‘orientationchange’ or ‘resize’ event on window.

// Detect whether device supports orientationchange event, otherwise fall back to the resize event.

var supportsOrientationChange = "onorientationchange" in window,
    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";

window.addEventListener(orientationEvent, function() {
    alert('Rotation of screen:' + window.orientation + " " + screen.width);
}, false);

You can then check the window.orientation property to figure out which way the device is oriented. With Android phones, screen.width or screen.height also updates as the device is rotated. This will not work in the case with the iPhone, because orientation change does not update screen.width or screen.height.

, , , , , , ,

23
Feb

Replace String Function in Javascript is used to replace the specified characters with new characters in the provided string.
Syntax:
stringObject.replace([string pattern to find],[new string]);
Example:

var myString = new String();
myString = "This is first example";
document.write(myString.replace(/ /,"-"));

Above example will replace the first occurrence of space with hyphen “-”.

Output: This-is first example

, , , ,

23
Feb

Split Function in JavaScript is used to split any string into two or more parts by passing the separator character in the split function. Split function splits a string into an array by storing the first part at first index, second part at second index and so on.

Syntax:
stringObject.split( [separator character] );

example:

<pre class=”brush:js”>

<script type=”text/javascript” language=”javascript”>
var myArr = new Array();
var myString = new String();
myString = “1,2,3,4,5,6,7,8,9″;
myArr = myString.split(“,”);
for(var i=0;i<myArr.length;i++)
{
document.write(“Array Index ” + i + ” = ” + myArr[i] + “<br />”);
}
</script>

</pre>

, , ,

14
Feb
Trim is a string manipulation function or algorithm.This Javascript code trim implementation removes all leading and trailing occurrences of a set of characters specified. If no characters are specified it will trim  whitespace characters from the beginning or end or both of the string.
Example:

<html>
<script language="JavaScript" type="text/javascript">
String.prototype.trim = function ()
 {
 return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
var s = new String(" Hello ");
s=s.trim();
alert("!" + s + "!");
</script>
</html>

, ,

11
Feb

Here I’ll demonstrate how to develop and deploy application for Symbian OS, using Aptana Studio. (Windows platform)

Download Aptana Studio and install it from,

http://aptana.com/products/studio2/download

Download Nokia WRT plug-in for Aptana Studio and install it from,

http://goo.gl/LxQye

After completing the above steps, start Aptana Studio

Select File >> New >> Project

Under Nokia Web Runtime (WRT), select New Nokia Web Runtime Widget and click Next.


More »

, , , , , , , , , , , , , , , , , , , , , , , ,

28
Jan





Refresh in 4 seconds


, ,

05
Oct

This is the source code to create an image slide show in javascript:
More »

, , , , , , , , , ,

12
Feb

Besides W3Schools one site with a really helpful tutorial for jQuery that any beginner can browse through easily is

the Web Designer Wall.

http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/

This tutorial is not just clear and to-the-point, it is also very bright and bold in presentation. It has 10 really helpful visual tutorials on jQuery in an easy to understand, user-friendly format.

Having a tough time with jQuery? This is your perfect solution!

P.S: Before you go here, make sure you have done your home work well and know your JavaScript and CSS well… Good Luck!

, , ,