To execute a function inside in external .js file

To execute a function inside in external .js file, use $( window ).load. $(document).ready(function(){ is used to load .js file or loading js functions but those functions won’t be execute. create set_user_status.js file, it looks similar to this: function setUserStatus(v1,v2,v3){ alert(v1+ v2+ v3); //or console.log(v1+ v2+ v3); } The header will preload the external .js file like this: <script type=”text/javascript” src=”js/set_user_status.js”></script> To execute the function setUserStatus inside the external .js file, use $( window ).load $( window ).load(function() {//works setUserStatus( “value1”, “value2”, “value3”); });

Continue reading »

Keyboard code “KeyCode” and how to use it in JavaScript

To work on HTML5 canvas to develop a tool similar to paint or free draw on an image, JQuery and Javascript are often used on the browser client side to perform simple tasks that would otherwise require a full postback to the server. There’re a set of keycode associated with each character on the keyboard. To use this on your canvas on an html page, add JQuery and JavaScript to detect the key that user pressed as follow: Key Code backspace 8 tab 9 enter…

Continue reading »

How to detect screen resolution

PHP does not provide native function that can detect the device display resolution. Java Script can be used in this case, which will detect the display resolution. The script will do so, by using the width and height features of the screen. The required code for this has to be inserted into a HTML document. Once it is done, the settings can be switched to the PHP script through proper coding methods. This will be the codes that you can use to make your website…

Continue reading »

How to display Prev/Next buttons on a Nivo slider when MouseOver

Most of slider effects will display the Prev/Next buttons by default once you open the page that contain a slider effect. Whether you build a slider for a CMS or a shopping cart or a regular HTML page, you can be able to change the codes in CSS and slider block on your HTML page. Here’s how you do it. Open the CSS file that supports the slider, add a style for the Prev/Next layer. Hide the layer on display first. .parent .navigation-links { display:none;…

Continue reading »

How to stop a webpage from auto refreshing constantly

There’re a few questions related to this matter I received today from my clients. Some of them have tried “break;” and “window.stop();” and “pause();” and “window.location.reload(false);”, … you name it; however, non of them works. There’s a trick to reload a webpage once and stop the webpage from auto-refreshing itself. At the end of the URL, add the pound sign like this # in the Get or Post URL. Then when you retrieve the value by GET/POST variables, remember to remove the # sign by…

Continue reading »