ondemand

How to load Google's Custom-search-engine(CSE) JS APIs after page loads?

纵饮孤独 提交于 2019-11-28 01:50:22
问题 I am using Google Custom Search Engine with their new auto-completion feature. I want this whole javascript to be loaded AFTER the page itself is loaded. The original Google code is this: <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('search', '1'); google.setOnLoadCallback(function() { google.search.CustomSearchControl.attachAutoCompletion( 'some-long-unique-id', document.getElementById('q'), 'cse-search-box'); }); <