I have a MODx Revolution site (v2.2.2-pl) which has a page with many downloadable PDF file links. The client wants to be able to have site visitors search the content of these PDF files.
I found some code that has been successful in helping me do that (from another forum post, circa 2008) by utilizing Google's ability to search the content of PDF files and offer them up as search results. The code looks like this:
<script type="text/javascript">
function SearchPDF()
{
var site = "www.sample.com";
window.location.href = "http://www.google.com/search?hl=en&q="
+ document.getElementById("txtPDFSearch").value
+ " site:" + site + " filetype:pdf";
}
</script>
<input type="text" id="txtPDFSearch" />
<input type="button" id="btnPDFSearch"
onclick="SearchPDF();" value="Search The PDFs" />
It works well but when you click the button to have it perform the search, it takes you to Google and abandons my site. The client would like to have the search results appear on their site, like within an iFrame or something. However, I'm thinking that Google may be employing some kind of framekiller to stop this from happening. Can anyone confirm Google does this?
Is there any way to do this through a MODx site? Any component or something that can produce an iFrame-like experience? Anyway I can modify the above code to do such a thing? I may be willing to have the page just open another browser window (like some kind of target="_blank" type of thing) so long as it doesn't completely abandon my site. I'm not sure how to go about that with the above code, though. I know the code change involves changing the window.location.href part to a variation of window.open(......) but I haven't been able to get the right combination yet.
Thank you in advance.
[ed. note: waizen last edited this post 12 years, 1 month ago.]