Free Android CakePHP GMaps Articles by Bali Web Design

July 21, 2010

Sleep or wait process on javascript thread

Filed under: html,javascript — admin @ 10:10 pm

Actually there is no Thread.sleep method on javascript that work on Threading. Moreover there is no true threading in javascript. So everybody that want to deal with threading need to emulate it. In this article i would like to show you some method that emulate sleep method for waiting on a process. Each of this method has each own disadvantage, so you need to choose which is suitable for your case.

First method is sleep using javascript loop. This is first method that come to my mind when emulate sleep method on javascript. We wait for the process by checking the time in the loop.

function wait(millisecond) {
var date = new Date();
var current_date = null;

do { current_date = new Date(); }
while(current_date-date < millisecond)

// do something
wait(1000); // wait 1000 millisecond
// do something


How to handle user closing browser windows or page using javascript

Filed under: html,javascript — admin @ 12:40 am

Sometime we need to handle or do something when user closing a browser windows or page. Maybe we want to ask user if they really want to close the page or it was a mistake click. This procedure all can be done using javascript.

There are two condition or event that you can intercept before it really happen, first when user close the browser windows and second is when browser windows will be closed without any way to abort it.

For first condition we can handle it using window.onbeforeunload event.

function closeHandler() {
return “Are you sure you want to close this page?”;

window.onbeforeunload = closeHandler;


August 31, 2009

How to print javascript object properties

Filed under: html,javascript — Tags: — admin @ 2:32 am

Sometime we need to print the structure data that return by a function. I was work on a task for google map and need to print object properties of Placemarks object on javascript. I need to analyze what kind of structure data return by geocoding function. The code below is a short function to print object properties in javascript

function isObject(obj) {
return obj.constructor == Object;

function print_object(object, level){
var tab = “”;
if(level > 0){
for(i = 0; i < level; i++) tab += “\t”;
var str = “”;
for(prop in object) {
if(!isObject(object[prop])) str += tab + prop + ” value :” + object[prop] + “\n”;
else str += tab + prop + “\n” + print_object(object[prop], level + 1);
return str;

and how to use this function is really simple approach

address = addresses.Placemark[0];
alert(print_object(address, 0));

in this scenario, i would like to print first placemark object return by geocoding function. Parameter level is use to make nice print view using tab character.

June 22, 2009

How to check nofollow link on firefox?

Filed under: css,html — Tags: — admin @ 12:36 am

As a SEO master, sometime we need to add backlink from another sites to our sites. More backlink can give good SEO credit to your website, of course best if the backlinks come from high page ranking site and have related content with our website.

There are many free resources to get free backlink to you, for example social networking site, social bookmarking site, or blog comments. Important to check if the link give to you is a dofollow link type. Only dofollow link type can give SEO credit to your websites. This rule is apply at least to Google Search Engine.

How to check if the sites can give you dofollow link to your websites? simple way is by view page source on the websites and check if the link contain rel=”nofollow” attribute. If it has then that website cannot give you a backlink. Another thing is to use a plugin or tool to check if the website using dofollow or nofollow link. But until this time, i don’t find a good tool for that. I am to lazy also to view page source and read through the html code if the link using nofollow or not.

I need an easy way to check the link, that means when loading, the browser must give a sign on nofollow link. I believe this way is more faster to check about it. I found a simple solution for firefox. The idea is to add user define style to firefox. So everytime we load a web page, that css will override all style defined.

To do it, please create or edit a file named userContent.css in C:\Documents and Settings\{Your User}\Application Data\Mozilla\Firefox\Profiles\{random string}\chrome. And then add this line into last line :

a[rel*=”nofollow”] {
border: 1px dashed black;
background: #FFFF99;

And then save it. Please restart firefox to load the setting. Now, if you open a website with nofollow link, you will get a link with dashed border and #FFFF99 background color.

The first link is a nofollow link, and second link is dofollow link.

September 20, 2008

How to load javascript file on window on load

Filed under: html,javascript — Tags: , — admin @ 7:36 pm

Here is another way to load a javascript file on window on load.

<script type="text/javascript">
window.onload = function () {
var script = document.createElement("script");
script.src = "site/js/3000297746.js";

August 1, 2008

Yellow background on HTML text field Form

Filed under: html — Tags: , — admin @ 10:05 am

Have you ever found a confusing condition on your browser IE or Firefox that when you open an HTML Form page some text field has yellow background even you dont have this color on your css or html.

This situation also make me confuse because my client said that he saw yellow background on a computer but on another computer he doesn’t see yellow background. He want to know the answer why.

I was already thinking about this confusing thing before, but i didn’t try to find more detail about this problem. But i know this is something to do with the plugin on browser. Something like auto complete form.

So i go to forum and found the reason. According to the forum, it is because we use google toolbar for auto complete capability when we input data on HTML form. So we can set an auto complete form when we fill another html form later.

To disable the toolbar just go to View > Toolbars > Google Toolbar. And then refresh the browser. The textfield background will colouring with its original color.

July 29, 2008

How to post form into a popup window

Filed under: html,javascript — Tags: , — admin @ 10:04 am

When you need to send a variable to a popup window from mainpage, ussually we will put it in url as GET method. But using this problem we will get problem when the variable has long character. We know that GET has limited long.

So we need to use POST method to submit a form. But how we can do it? I have a trick how to do it.

First we create a javascript for handling onsubmit event on html form.

function thePopupWindows(windowsname){
var win ='', windowsname, ''width=580,height=450');
return true;

and then set this function on HTML Form :

<form action="popupwin.php" method="post" target="thepopup" onsubmit="return thePopupWindows(;">
<input id="name" name="name" type="text" />
<input type="submit" value="Submit">

July 10, 2008

Add page break on HTML page

Filed under: html — Tags: — admin @ 10:03 am

Sometimes we want to add a page break on specific part on the page for printing. We can do it with simple css method for adding page break on specific part that you want a page break is occur.

So when you need to add page break on specific place, you just need to add this html code :

<p style="page-break-before: always">

on part that you want a page break occur.

for example :

<p>This is page 1</p>
<p style="page-break-before: always">
<p>This is page 2</p>

If we print this html, we will have two pages printed.