Archive for the ‘Java Script’ Category

Simple JavaScript eval() function encoder/decoder/beautifier

Below tutorial will explain, how to encode/decode packed function, How to decode the Javascript packed script? Step1: Step 2: Convert eval function to alert & add it the html between <script></script> tags, and run the HTML file. Step 3: Once done step 2 & executed, original code will be alerted like below, Step4: Right click [...]

Calling Multiple Functions onclick Javascript

I am writing here to handle multiple Javascript functions in OnClick Event. To use multiple functions on Events, you want to add functions by separating with semicolon (;), For Ex: onclick = “testfun1(); testfun2();”. Each functions will run serially, first will be testfun1() and second testfun2(). To explain this functionality, I have enclosed working code [...]

Back and forward button in JavaScript

Sure you can ask your visitors to use their brower’s BACK and FORWARD buttons to navigate your site. Wouldn’t it be nice to have your own BACK and FORWARD buttons on your pages: All you have to do is place the following HTML tags on your page: <FORM METHOD=”post”> <INPUT TYPE=”button” VALUE=”BACK” OnClick=”history.go( -1 );return [...]

Restricting the input field with maxlength

Restricting the input field value with maxlength specified using the below javascript here, function textLimit(field, maxlen) { if (field.value.length > maxlen + 1) alert(’your input has been truncated!’); if (field.value.length > maxlen) field.value = field.value.substring(0, maxlen); } This function is called on the input text onkeyup events, like below <INPUT TYPE=”text” NAME=”dd” onkeyup=”textLimit(dd,10)”>

Page redirection depends upon visitors browsers

How to redirect visitors to different pages depending upon their browser using  java script. Is it possible? Yes, it’s possible. Here is the code, <script type=”text/javascript”> <!– var bname = navigator.appName; if (bname.search(/netscape/i) == 0) { window.location=”netscape.html”; } else if (bname.search(/microsoft/i) == 0) { window.location=”internetexplorer.html”; } else { window.location=”other_browsers.html”; } //–> </script> After assigning the [...]

Disable Right mouse click using Javascript

While I searching for disabling right click option using Javascript code. I found this code on one of web site, This code will disable right click popup and also it will protect our website content, source from stealing. This code can be used in any HTML page. Features: a) This javascript function will disable the [...]

Random Number Generation using java script

While i searching for code in internet for random number generation in javascript. I fond this code. I hope it will usefull for some developers to integrate this code in their work. Try this code. Get random number in javascript by using readymade function random(): alert(Math.random()); Function to generate random numbers between range 1 to [...]