The toSource() function, which we talk about yesterday(Javascript – Print an object with alert()), only works in Firefox, a more proper way which work in non Gecko engine browser like Chrome and Safari is using console. Continue reading Javascript – Print an object in console
Tag Archives: Javascript
Javascript – Print an object with alert()
During web development, sometimes we may need to print the whole Javascript object for debug purpose. You can simply dump the object to the alert box by toSource(). Continue reading Javascript – Print an object with alert()
CSS & jQuery – Hide the HTML page until the Javascript & CSS styles are completely loaded
It always takes some times for the browser to apply the CSS styles on the rendering page. Therefore, users may observe a style leap before the page is completely loaded. We could fix this problem by hiding the body anchor until the Javascript and CSS are loaded.
First, set the visibility of the body anchor to hidden. Continue reading CSS & jQuery – Hide the HTML page until the Javascript & CSS styles are completely loaded
Javascript – Add To Bookmark
I found a Javascript which is for adding bookmark to browser. Since Chrome and Safari do not support adding bookmark by Javascript, an alert box will be prompted and tell the user using Ctrl + D to add the bookmark instead. Continue reading Javascript – Add To Bookmark
Google – How to fix “This site may harm your computer”
If your website is marked as “This site may harm your computer” by Google, most likely your site is hacked. In that case, log in to Google Webmaster Tools and it will shows you which URLs are “infected”. This should help a lot to clean the malware.
So make sure you have configured Google Webmaster Tools for your live websites. Continue reading Google – How to fix “This site may harm your computer”
Drupal – Distorted GMap in Quick Tabs
The GMap module is a great tool to display Google map in Drupal. But when i try to render the GMap in Quicktabs, it is always distorted. Continue reading Drupal – Distorted GMap in Quick Tabs
Javascript – Get URL Query String
We can obtain the URL query string with the following Javascript function. Continue reading Javascript – Get URL Query String
Javascript – Check string contains
We can use the indexOf() function to check if a string exists in another string.
var s = "foo";
alert(s.indexOf("oo") != -1);
it returns true if s contains “oo” and vice versa.
Done =)
jQuery – Bind event to newly inserted element
If you have inserted DOM objects into the HTML in $(document).ready(function() {…}). Those binded events will not applied to newly inserted DOM objects. In the following example, a new button is inserted whenever the .btn is clicked. but it is only valid for the first .btn button. Continue reading jQuery – Bind event to newly inserted element
jQuery – Check/Select a radio input
The following jQuery code check/select a radio button.
$('#radio-input-id').attr('checked', 'checked');
Done =)