Connecting Tech Pros Worldwide Forums | Help | Site Map

Javascript keyword search description - what does this do?

Newbie
 
Join Date: Jul 2008
Posts: 28
#1: Nov 20 '08
hi,

i stumbled accross a piece of coding in the between the <head> tags where you normally put your keywords etc and one website i saw had this piece of javascript there.

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2. <!-- 
  3. //Keyword search function
  4.         function searchfocus() {
  5.             searchform.Query.focus();
  6. }
  7. //Compute search function
  8.     function computesearch() {
  9.         var pathValue = "/websites/UK/uk.nsf/SearchResults/?SearchView&Query=";
  10.         var queryValue = document.searchform.Query.value;
  11.         location = pathValue + queryValue;
  12. }
  13.  
  14. function windowOpener(url, name, args) {
  15. if (typeof(popupWin) != "object"){
  16. popupWin = window.open(url,name,args);
  17. } else {
  18. if (!popupWin.closed){ 
  19. popupWin.location.href = url;
  20. } else {
  21. popupWin = window.open(url, name,args);
  22. }
  23. }
  24. popupWin.focus();
  25. }
  26. // -->
  27. </script>
  28.  
Can anyone let me know what this is actually doing please?

Thanks

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Nov 20 '08

re: Javascript keyword search description - what does this do?


You're probably asking about this piece of code:
Expand|Select|Wrap|Line Numbers
  1. //Compute search function
  2.     function computesearch() {
  3.         var pathValue = "/websites/UK/uk.nsf/SearchResults/?SearchView&Query=";
  4.         var queryValue = document.searchform.Query.value;
  5.         location = pathValue + queryValue;
  6. }
It opens/redirects to a search results page for the query value entered in the "Query" input text box.
Reply


Similar JavaScript / Ajax / DHTML bytes