Tip: Open default browser from the HTML details view
April 23rd, 2008 | Published in Google Desktop API
When you use the HTML details view to display information, on Windows every link inside is opened using Internet Explorer, even if the user has another browser like Firefox or Opera set as their default browser. However, you can fix this with a few lines of code in your gadget.
The following link opens the Google web page in Internet Explorer in Windows — even if another browser is set as the default.
To remedy this, open the URL using JavaScript and theGo to Google
onclick
event.
This executes theonclick="window.external.openUrl('http://www.google.com');">
Go to Google
openUrl
method on the external object with the parameter of the URL you want to visit. What does this external object look like? Here is the JavaScript code that defines the external object and assigns it to the details view. This should be run before the details view is opened.
Now all your links will be opened in the default browser. Just don't forget to escape the URL!var externalObject = new Object();
externalObject.openUrl = function(url) {
framework.openUrl( url );
};
mydetailsview.external = externalObject;
Have a tip you'd like to share? Send it to gd-developer AT google DOT com. To see all tips, choose the Tips label.