Javascript Archives - 7-Views
Reverse Geocoding – Get formatted address from latitude and longitude
<script> function getmylocation(lat, lng) { var currAddress, addtress= []; var geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(lat, lng); if (geocoder) { geocoder.geocode({‘latLng’: latlng}, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[0]) { currAddress = results[0].formatted_address; addtress.push(currAddress ); } else { alert(‘No results found’); } } else { alert(‘Geocoder failed due […]
Adding ‘active’ class to open Bootstrap accordion item
![](https://7-views.com/wp-content/uploads/2018/08/kisspng-web-development-html-css3-the-ohana-code-logo-2cpaper-projection-shaded_1660937-html-dropdown-js-5aebd5634bb501.0344507315254050273101-e1535005847318.png)
Several times we want to have our own custom class on open tab of our bootstrap acoordion so that you can apply your custom css to it. A basic jQuery solution to add an ‘active’ class to the accordion heading of the currently active accordion item.
URIError: malformed URI sequence
The point is that if you use single % it breaks the logic of decodeURIComponent() function as it expects two-digit data-value followed right after it, for example, %20 (space). There is a solution to this. We need to check first if the decodeURIComponent() actually can run on given string and if not return the string as […]
Email Validation
function validateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\s@”]+(\.[^<>()\[\]\\.,;:\s@”]+)*)|(“.+”))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); }
How to check if a page is in an iFrame
function inIframe () { try { return window.self !== window.top; } catch (e) { return true; } }