Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using the Geolocation API in JavaScript

Is there no way style the permission box?

How do I style the prompt box that asks for permission to allow access to the client's location? It looks scary enough. I googled this question and found nothing but the documentation on geolocation, or the google maps API etc.

Actually, this box is not the same in all the browsers, and the message is not so UI friendly (I suppose). So is there any other way to get this permission? or maybe style it as I want to?

I want to style this box: https://prnt.sc/hzbi2a (if you're not clear about what I'm looking for.)

Thank you, Nafis Fuad

One more thing, I've noticed that Google doesn't require that permission. Why is that?

3 Answers

Steven Parker
Steven Parker
231,261 Points

Since this dialog is security-related, it's probably not possible to apply styling. If that were allowed, it would create opportunities for malicious scripts to thwart the purpose of the dialog.

Any site that provides location-specific information without requesting location data has probably stored your information from a previous session in a browser cookie. It might also be getting approximate location data based on your ISP.

Oh, I see. there's no way in styling that box... I'm gonna leave it as it is and go with the approximation method whenever possible. ( Maybe someday we can style that too ).

Shortly after I posted this, I found a few articles about getting approximate location through the IP address. There are a few API services too. The only catch is that they don't always produce the best results. And sometimes, they are horribly wrong.
Anyway, Thank you.

Steven Parker
Steven Parker
231,261 Points

Because of my connection, most web sites think I'm in a different state!

haha.... happens with me too...