... <body> <script> (function() { var cx = '009372546338520416759:-rdtwkgor4i'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:search></gcse:search> <body></html> search/templates/search/index.html Your Custom Search Identifier (aka CX or CSEid) The div element where to show the results
callback=hndlr"></script>'); } function hndlr(response) { .... } search2/static/js/script.js Your API key Your custom search engine id Your search query Your callback method
= 0; i < response.items.length; i++) { var item = response.items[i]; var link = item.link; page += "<br/><div><a onclick=\"go('"+link+"');\" href='#'>" +item.htmlTitle +"</a><br/>" +item.htmlSnippet+ + "<br/><a onclick=\"go('"+link+"');\" href='#'>" +link+"</a></div><br/>"; } $('#result').html(page); $('#result').show(); } search2/static/js/script.js For each search ... display the search result but change the target url address so that the link opens in the current page rather than opening a new one
scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.” Wikipedia
another HTML document possibly coming from another domain ➡ Like a webpage inside a webpage ✓ An iFrame is acting like a fence between the two documents <html> . . . <iframe> </iframe> . . . </html> <html> </html> Javascript code from the inner document cannot access the resources from the main document and vice versa