選択した文字列をGoogleマップで検索するブックマークレット
賃貸サイトで物件の所在地をすぐに確認したいので作ってみた。
ただGoogleマップを開くだけという手抜きシンプル設計。
IE8とFirefox3.5のみ動作確認済。
ソース
javascript:(function(w,d){var address=w.getSelection?w.getSelection().toString():d.getSelection?d.getSelection():d.selection?d.selection.createRange().text:null;if(address)w.open("http://maps.google.com/maps?q="+address,"map","width=800, height=800");})(window,document);
内容
javascript: (function(w, d){ var address = w.getSelection ? w.getSelection().toString() : d.getSelection ? d.getSelection() : d.selection ? d.selection.createRange().text : null; if (address) w.open('http://maps.google.com/maps?q='+ address, 'map', 'width=800, height=800'); })(window, document);
ちなみに
最近はBookmark Builderでブックマークレットを作るのがマイブーム。
ワンクリックでCompressできるので良い感じ。