2013-05-21 51 views
-5

如何獲得使用JavaScript在Google搜索文本框中編寫的文本?我正在開發一個Mozilla擴展,我使用多個函數在Google工作表(Google Docs)中編寫Google搜索的結果,除了關鍵字之外,我已經擁有了我需要的所有東西。獲取谷歌搜索中使用的關鍵字

+0

使用JavaScript _in what_? – SLaks

+0

您是否使用谷歌的某種片段?我們需要代碼才能夠幫助你。 –

+2

我想你試圖做到這一點:http://stackoverflow.com/questions/907305/how-does-a-website-highlight-search-terms-you-used-in-the-search-engine?看看Referer(原文如此)頭。 – NullUserException

回答

0

我解決它使用正則表達式

/* get keyword */ 
var url = $('txtbox_location').getAttribute('value');; 
var match = /&q=([^&]+)/.exec(url); 
var keywordU = unescape(match[1]); 
keywordU = keywordU.replace('+', ' '); 
Application.console.log(keywordU); 

其中txtbox_location是一個文本框,在其中我有當前的URL