2013-10-15 32 views
-2

我正在嘗試在Google協作平臺中包含一個簡單的javascript,但按下按鈕時我什麼也得不到。我把代碼放在一個HTML Box中。在本地測試時,代碼完美工作。這裏是我的代碼:將Javascript包括到Google Sites中

<script type="text/javascript"> 
var catalog_host_name = 'destiny.frederick.k12.va.us'; 
var site_id = '115'; 
var context = 'saas29_0418957'; 

function search(ty) {window.open("http://" + catalog_host_name + "/cataloging/servlet/handlebasicsearchform.do?searchType=" + ty + "&redisplay=false&includeLibrary=true&siteTypeID=-2&keywordText=" + document.getElementById('findTerms').value + "&site=" + site_id + "&context=" + context + "&redisplay=false", "searchWindow", "width=800,height=600,scrollbars=yes"); 
} 

</script> 

回答

0

很難說肯定,我的猜測是,有沒有與'findTerms'爲id的元素。這意味着document.getElementById('findTerms')將爲null,這意味着它沒有value屬性(所以document.getElementById('findTerms').value失敗,因爲:TypeError: Cannot read property 'value' of null)。

確保元素存在,並且value屬性返回所期望的值(您可以使用集成在瀏覽器中的chrome開發人員工具)。