-1

I have a search bar and when I press the search button it will look for keywords in the text file that you have on your computer, then bring to me the words that are found back to the page?

document.getElementById('frmSearch').onsubmit = function() {
  window.location = 'http://www.google.ro/search?q=' + document.getElementById('txtSearch').value;
}
<form id="frmSearch"  class="search1" method="get" action="default.html" />
<input class="search" id="txtSearch" type="text" name="search_bar" size="31" maxlength="255" value="" 
        style="left: 396px; top: 20000px; width: 293px; height: 60px;" />
     <input class="search2" type="submit" name="submition" value="Cauta" style=" padding-bottom:20px; left: 300px; top: 0px; height: 50px" />
     <input class="search2" type="hidden" name="sitesearch" value="default.html" />
Mahdi Alkhatib
  • 1,954
  • 1
  • 29
  • 43
Horia
  • 11
  • 1

2 Answers2

0

Sorry, scripts can only perform web-related actions. Accessing local files is unsafe and forbidden for secure reasons.

UPD: for an offline app you can use something like this:

var fileRequest = new XMLHttpRequest();  
fileRequest.open('GET', 'file://[your file path]', false); 
fileRequest.responseText // it is yours text  
S. Nadezhnyy
  • 582
  • 2
  • 6
  • yes ,but i dont want my page to be online...i want to offer a better look to my text file...i want only to search in the text file for key word and bring me the info in my local host graphical interface. –  Horia Feb 15 '16 at 09:51
  • that way it is possible. See my UPD – S. Nadezhnyy Feb 15 '16 at 10:01
  • where i need to put the UPD? replace the javascript? –  Horia Feb 15 '16 at 10:03
  • and do you have any idea how i do when i click on the search button to start a command on windows/ linux (that need to works in parallel with the text file search )???? –  Horia Feb 15 '16 at 10:06
  • Use some server-side language, e.g. PHP or node.js. – nhaa123 Feb 15 '16 at 10:25
-1

@Horia, you should be using the Google Search box and their custom search engine with API, instead of an iframe. This stack overflow might solve your problem. What are the alternatives now that the Google web search API has been deprecated?

Community
  • 1
  • 1