Friday, 14 October 2011

Why do I receive an "Operation aborted" error message when I visit a Web page in Internet Explorer?

This problem occurs because a child container HTML element contains script that tries to modify the parent container element of the child container. The script tries to modify the parent container element by using either the innerHTML method or the appendChild method.

For example, this problem may occur if a DIV element is a child container in a BODY element, and a SCRIPT block in the DIV element tries to modify the BODY element that is a parent container for the DIV element.

http://support.microsoft.com/kb/927917

Friday, 7 October 2011

Calculate last date of given month using JavaScript

<html>
<body>
The end date of this month is
<script type="text/javascript">


//Today
var d = new Date();

//var d = new Date(2011, 10, 1);
//alert(d);

//End date of this month
var d = new Date(d.getFullYear(), d.getMonth() + 1, 0);

//alert(d);

var monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December' ];
var endDate = d.getDate() + ' ' + monthNames[d.getMonth()] + ' ' + d.getFullYear();

//alert(endDate);

document.getElementById('prizeDrawEndDate').innerHTML = endDate;

</script>




Click here to try it by copying the script into w3schools try it editor

Friday, 5 August 2011

Using Fiddler with HTTPS

By default Fiddler doesn't allow you to view and inspect the details of requests made via HTTPS.

This can be done if you enable "Decryption of HTTPS traffic"

Go to Tools >> Fiddler Options >> Select HTTPS tab >> Select "Decrypt HTTPS traffic" if it is not already selected.

When you select this option Fiddler will popup two warning message boxes, one after the other. First one will say something like "Fiddler generates a root CA certificate to intercept HTTPS traffic". Click "Yes" then it will popup another message box saying "You are about to install a certificate from CA...". Click "Yes" again.

That is it. You can start debugging HTTPS traffic now.

http://www.fiddler2.com/fiddler/help/httpsdecryption.asp

Thursday, 4 August 2011

Disable hardware acceleration in Firefox

When dual monitor is used, and firefox is on the second monitor, the Firefox menu doesn't show up. Same happens to the address bar when typing previously visited sites.

If you experience this problem disabling hardware acceleration might fix it.

To disable hardware acceleration in Firefox follow below steps

In the Options window, select the Advanced → General tab.

Then un-check the checkbox labeled "Use hardware acceleration when available".

Click OK

Friday, 29 July 2011

jQuery Plug-ins : how to build?

Plugin Authoring Guidelines
http://docs.jquery.com/Plugins/Authoring

Building Your First jQuery Plugin
http://blog.jeremymartin.name/2008/02/building-your-first-jquery-plugin-that.html

A Plugin Development Pattern
http://www.learningjquery.com/2007/10/a-plugin-development-pattern

Wednesday, 27 July 2011

Hiding JavaScript code from older browsers

It is straighforward, follow the steps below:

1. Immediately after the opening <script> tag, put a one-line HTML-style comment without the closing characters, so that the first two lines of your script would look like this:

<script language="JavaScript">
<!--


2. At the end of your script, put the following two lines:

//-->
</script>


Thus, your HTML file will contain the following fragment:

<script language="JavaScript">
<!--
Here you put your JS code.
Old browsers will treat it
as an HTML comment.
//-->
</script>

Old browsers will treat your JS code as one long HTML comment. On the other hand, new JavaScript-aware browsers will normally interpret JS code between the tags <script> and </script> (the first and last lines of your JavaScript code will be treated by the JavaScript interpreter as one-line comments).

Tuesday, 26 July 2011

Auto-boxing JavaScript primitive types

Primitive Types in JavaScript

Number values, like 1,
string values, like "",
the boolean values true and false,
and the special values null and undefined

Object types in JavaScript

Date objects,
regular expression objects,
function objects,
arrays
and literal objects like {}

Auto-boxing
Whenever you access or assign to a property of a number, string or boolean, a temporary object value (of the Number, String or Boolean class, respectively) is created with the same naked value as the primitive value, but that temporary object is only available to that property access, and does not replace the primitive value that your variable references.

Example

Calling split() on primitive value.


var str = 'primitive-valued string literal';
console.log( str.split(' ') ); //=> obviously ["primitive-valued", "string", "literal"]
str.split = function(){ return 'overridden!'; };
console.log( str.split(' ') ); //=> still ["primitive-valued", "string", "literal"]


Calling split() on String object.


var str = new String( 'primitive-valued string literal' );
console.log( str.split(' ') ); //=> obviously ["primitive-valued", "string", "literal"]
str.split = function(){ return 'overridden!'; };
console.log( str.split(' ') ); //=> "overridden!" that's more like it


Read more >>