Step 1: Goto https://www.google.co.in/cse/
Step 2: Click on Sign
in to Custom Search Engine from
following page.
Step 3: Login with google account
Step 4: Click on Create A Custom Search Engine from following page.
Step 5: Input website address in following
On following page
Specify the search engine name in following textbox
On the same page.
Step 6: Click on following button on the same page
Step 6: Click on following button
Following page
Step 7: Following page with script will open
Copy the following 'cx' value
Step 8: Add the above cx value to following javascript
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('search', '1');
function OnLoad() {
var s = window.location.search;
if (s.indexOf('?keyword=') >= 0) {
s = s.substring(s.indexOf('?keyword=') + 9);
if (s.indexOf('&') >= 0) {
s = s.substring(0, s.indexOf('&'));
}
}
else {
s = "";
}
for (var i = 0; i < s.length; ++i) {
if (s.indexOf('+') >= 0) {
s = s.replace('+', ' ');
}
}
var customSearchControl = new google.search.CustomSearchControl('Your CX value Here');
customSearchControl.draw('search-result');
customSearchControl.execute(s);
}
google.setOnLoadCallback(OnLoad);
</script>
Step 9: Paste this javascript to your view.
0 comments