我想在一個網站上實現一個簡單的腳本,它會從google的ajax API返回base64編碼的信息。這是我與迄今玩:如何base64編碼在javascript裏面
<html>
<head>
<script src="http://www.google.com/jsapi?key=ABQIAAAA0duujonFsEX871htGWZBHRS76H0qhS7Lb-D1Gd0Mnaiuid8Z7BQIyz2kMpojKizoyiCQA4yRkKAKug" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
var location = 'Unable to determine your location.';
if (google.loader.ClientLocation) {
var loc = google.loader.ClientLocation;
location = 'Country: <strong>' + loc.address.country + '</strong>, Region: <strong>' + loc.address.region + '</strong>, City: <strong>' +
loc.address.city + '</strong>, Lat/Long: <strong>' + loc.latitude + ', ' + loc.longitude + '</strong>';
}
jQuery('.geolocation').html(location);
});
</script>
</head>
<body>
<span class="geolocation"></span>
</body>
</html>
它返回我試圖得到正確的信息,但我需要Base64編碼,獨立的部分,如國家,地區,城市,緯度和經度。在PHP中它會很簡單,但我不知道如何在JavaScript中做到這一點。任何幫助,將不勝感激。
可能的重複[你如何使用Javascript編碼到Base64?](http://stackoverflow.com/questions/246801/how-can-you-encode-to-base64-using-javascript) – 2010-09-23 09:04:05