How to fix “operational abort” for Google Map in IE

The first task that I have to day is to fix Google Map “Operational Abort” in IE (Internet Explorer). It took me awhile to understand what happened at the back of it.

This is how to produce the error:

Go to any page with Google Map using the Internet Explorer.

Then go to another page, for example, by clicking the link from that page.

Hit “Back” to go back to Google Map page.

You will then receive “Operational Abort” error.

To solve it, I used the WindowOnload fix from: http://blog.firetree.net/2005/07/17/javascript-onload/

Here is how I used it, assuming that the code structure looks like this:

HTML HEAD

SCRIPT to include GMap Code

SCRIPT to ask GMap to do a cool trick – include GMap_init() function

HTML BODY

DIV your map is here

END HTML BODY

END HTML HEAD

The edited code:

HTML HEAD

HTML BODY

DIV your map is here

SCRIPT to include GMap Code

SCRIPT to ask GMap to do a cool trick

function WindowOnload(f) {
var prev=window.onload;
window.onload=function(){ if(prev)prev(); f(); }
}

WindowOnload(GMap_init); // call init() function.

END HTML BODY

END HTML HEAD

Feel free to try that out and let me know if it works 🙂

Include javascript in an external js file

This is how to include a script into an external javascript file. This is also similar to PHP include() statement.

document.write(“<script type=’text/javascript’ src=’JAVASCRIPT_URL_JS’></script>”);

Change For Attribute for Label Tag

This is a way to change for attribute value for label with Javascript.

<label id=”myLabel” for=”something”>my label</label>

Normal way:

document.getElementById(‘myLabel’).htmlFor = “another thing”;

Prototype JS way:

$(‘myLabel’).htmlFor = “another thing”;