Wednesday, April 23, 2008 at 4:34 PM
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 the<a target="_blank" href="http://www.google.com">Go to Google</a>
onclick
event.This executes the<a target="_self" href="#"
onclick="window.external.openUrl('http://www.google.com');">
Go to Google</a>
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.
4 comments:
How do I find the coding for the desktop "gadget"? I'd like to make the change so it will open Firefox instead of IE.
/egs
I need to open the url in a default browser. But the code above is not executing properly. I am using directly the code in java script and it's not executing. Please let me know what I am doing wrong:
tbxss is the one which is passed in javascript function:
var externalObject = new Object();
externalObject.openUrl = function(tbxss) {
framework.openUrl( tbxss );
};
window.external = externalObject
}
]]>
Or in directly calling in my function:
window.external.openUrl('http://www.google.com');
But it doesn't work at all.
window.open works fine but only in Firefox.. So please help me...
Insufficient information. No example. Tried the code, didn't work. Please update this!
This code doesn't seem to work...
Post a Comment