How To Scroll to the Top of the Page using Javascript

Author: , March 20th, 2018

window.scrollTo(x-coord, y-coord); Example: window.scrollTo(0,0);

How To Allow Cross-Site Javascript Using Apache

Author: , September 24th, 2015

The key is to send a response header like this: Access-Control-Allow-Origin: * In the Apache web server, one enables this via the following directive: Header set Access-Control-Allow-Origin * This requires the use of mod_headers, which is enabled by default in Apache. For example: 1 2 3 4 5 6 7 8 9 LoadModule headers_module modules/mod_headers.so […]

How To Fix JavaScript Floating Point Errors

Author: , February 27th, 2015

The .toFixed(2) method will round off the value of the field to 2 decimal places 1 decimalNumTwoPlaces = parseFloat(this.value.toFixed(2)); decimalNumTwoPlaces = parseFloat(this.value.toFixed(2));

How To Fix WordPress 3.8 Bugs

Author: , January 29th, 2014

Edit the wp-config.php file in the root of your WordPress Install. Search for this line: require_once(ABSPATH . ‘wp-settings.php’); Just before it add this line: define(‘CONCATENATE_SCRIPTS’, false ); Save, exit and refresh the page in your browser. It would also be a good idea to empty your browser cache. Original Post: http://www.carnfieldwebdesign.co.uk/blog/wordpress-fix-add-media-button-not-working/

How To Get the URL in Javascript Without the Query String

Author: , August 29th, 2013

window.location.href.split(‘?’)[0]

How To Modify the Menu Width in jQueryUI Autocomplete

Author: , June 18th, 2013

1 2 3 open: function( event, ui ) {     jQuery(’.ui-menu’).width(’220px’).css(’text-align’, ‘left’); } open: function( event, ui ) { jQuery(‘.ui-menu’).width(’220px’).css(‘text-align’, ‘left’); }

How To Add JavaScript or jQuery to a WordPress Page

Author: , October 4th, 2012

NO Blank Lines! 1 2 3 4 5 6 7 8 9 10 11 <script type="text/javascript"> <!– jQuery(document).ready(function(){  jQuery(’#yourForm’).on(’submit’, function(e){    if (jQuery(’#yourInput’).val() < 1) {       alert(’Please enter a whole number greater than 0′);       return false;    }  }); }); //–></script> <script type=”text/javascript”> <!– jQuery(document).ready(function(){ jQuery(‘#yourForm’).on(‘submit’, function(e){ if (jQuery(‘#yourInput’).val() […]

How To Round And Format Numbers In JavaScript

Author: , September 23rd, 2012

1 2 3 4 5 var num = 10; var result = num.toFixed(2); // result will equal 10.00   var num= 170.2305; var result = num.toFixed(3); // result will equal 170.231 var num = 10; var result = num.toFixed(2); // result will equal 10.00 var num= 170.2305; var result = num.toFixed(3); // result will equal […]

How To Get the Current URL in Javascript

Author: , September 6th, 2012

var pathname = window.location.pathname;

How To Replace All Line Breaks With <br /> Using JavaScript

Author: , April 16th, 2012

1 yourUpdatedVar = yourOriginalVar.replace(/\n/g, ‘<br />’); yourUpdatedVar = yourOriginalVar.replace(/\n/g, ‘<br />’);