Disable the back button on a browser
<script language="javascript" type="text/javascript">
function noBack()
{
window.history.forward()
}
noBack();
window.inhibited_load=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack()}
window.inhibited_unload=function(){void(0)}
</script>
Disable the Right Click of Mouse
<script LANGUAGE="JavaScript">
<!--
function click()
{
if (event.button==2)
{
alert('You Can NOT use the Right Mouse Button . No Sorry , It is my manager's spec!');
}
}
document.onmousedown=click
// -->
</script>
More will added in the next few days....
Programming help in Java , JavaScript, .Net, PHP, webservices , XML, Jquery etc.,
Showing posts with label Debug JavaScript. Show all posts
Showing posts with label Debug JavaScript. Show all posts
Thursday, January 13, 2011
Wednesday, January 5, 2011
Java : Error Patterns in Programming - The Top errors List-1
1. Accessing non-static member variables from static methods (such as main)
This is a quite often committed mistake especially who are newly introduced to java.Your first few days with java can be a real mess with this error.
Take for example the following application, which will generate a compiler error message.
public class StaticDemo
{
public String str1 = "teststr";
public static void main (String args[])
{
// Access a non-static member from static method
System.out.println ("This generates a compiler error" + str1 );
}
}
If you want to access its member variables from a non-static method (like main), you must create an instance of the object.
Here's a simple example of how to correctly write code to access non-static member variables, by first creating an instance of the object.
public class Non-StaticDemo
{
public String str1 = "tststr";
public static void main (String args[])
{
NonStaticDemo nsd = new NonStaticDemo();
// Access member variable of demo
System.out.println ("No error here" + nsd.my_member_variable );
}
}
---------------------Please click on "more" below for the enitre list -------------------------
This is a quite often committed mistake especially who are newly introduced to java.Your first few days with java can be a real mess with this error.
Take for example the following application, which will generate a compiler error message.
public class StaticDemo
{
public String str1 = "teststr";
public static void main (String args[])
{
// Access a non-static member from static method
System.out.println ("This generates a compiler error" + str1 );
}
}
If you want to access its member variables from a non-static method (like main), you must create an instance of the object.
Here's a simple example of how to correctly write code to access non-static member variables, by first creating an instance of the object.
public class Non-StaticDemo
{
public String str1 = "tststr";
public static void main (String args[])
{
NonStaticDemo nsd = new NonStaticDemo();
// Access member variable of demo
System.out.println ("No error here" + nsd.my_member_variable );
}
}
---------------------Please click on "more" below for the enitre list -------------------------
Debug JavaScript - Firefox, IE , Opera, Safari , Chrome
This document provides a brief summary of techniques for debugging JavaScript in various popular web browsers.
The instructions assume that you are running Microsoft Windows, but most of the techniques will work on any operating system.
Firefox
To view JavaScript error messages, you can launch Firefox's error console by selecting Tools → Error Console from the Firefox main menu. You may wish to set the preference
javascript.options.strict to true to get additional JavaScript warnings. (But note that this will reduce performance.)Alternatively, you can install the Firebug extension. Firebug provides a Console tab which will display JavaScript errors. Firebug also provides a JavaScript debugger to execute JavaScript code one line at a time, examine the values of variables, and so on.
To log information to the Firebug console, use the
console.log function:var x = 123; console.log("x = " + x);
Another useful tool for Firefox is the Web Developer extension.
To view the generated HTML source of a document, you have several alternatives:
- Select Edit → Select All from the Firefox main menu, then click the right mouse button and select View Selection Source from the context menu.
- Install the Firebug extension. Firebug's HTML tab shows the Document Object Model (DOM) of the generated HTML source of a document.
- Install the Web Developer extension. From the Web Developer menu, select View Source → View Generated Source.
- ------- Click below on more for IE6, IE7, IE8, Opera , Safari and Chrome debug information-------
Subscribe to:
Posts (Atom)