篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript Google Map It Bookmarklet相关的知识,希望对你有一定的参考价值。
javascript:(function(){function T(f){try{if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text}catch(e){}return ''}function A(f){var t=T(f);if(t)return t;for(var i=0;i<f.length;i++){t=A(f[i]);if(t) return t}return ''}var a=encodeURIComponent(A(window.top).replace(/[
]+/g,", ").replace(/\s+/g," "));if(a)window.open("http://maps.google.com/maps?q="+a)})();
//Here it is expanded so you can read it:
javascript:(function(){
function T(f) //get the selected text in frame f
{
try{
if(f.getSelection) return f.getSelection().toString();
if(f.document.selection) return f.document.selection.createRange().text;
}catch(e){} //if the frame is in another domain
return '';
}
function A(f) //get the selected text in frame f and its children
{
var t = T(f);
if(t) return t;
for(var i=0; i<f.length; i++) //for each child frame
{
t = A(f[i]);
if(t) return t;
}
return '';
}
var a = encodeURIComponent(A(window.top).replace(/[
]+/g, ", ").replace(/\s+/g, " "));
if(a) window.open("http://maps.google.com/maps?q="+a);
})();
以上是关于JavaScript Google Map It Bookmarklet的主要内容,如果未能解决你的问题,请参考以下文章