View Full Version : <iframe> search problem

12-21-2007, 10:04 PM
Hi all,
I was trying to make a working demo of an iframe that would display a search query that is input from an independent page


but on the results page, the searchbox automatically displays a "?" quetionmark before the word and if you keep clicking the "Submit Query" button, it keeps adding "q=%3F" along with the word

also, if you search two words, like "hello world" it inserts a "?" question mark and "%20" in the searchbox..

how do I get rid of the "?" marks and other characters appearing in the textbox?? :confused:

many thanks.. :)

12-21-2007, 11:38 PM
Your first page is acceptable, it might be able to be changed to make things less complex on the second page, I'm not sure. The results.htm should look like so:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>New Document</title>
<script type="text/javascript">
function init()
document.getElementById("googleFrame").src = "http://google.com/search?q=" + unescape(window.location.search.replace(/^\?/,''));
document.getElementById("q").value = unescape(window.location.search.substring(1));

window.onload = init;
<form action="http://google.com/search" target="googleFrame">
Search : <input id="q" name="q"><input type="submit"><br>
<iframe name="googleFrame" id="googleFrame" height=500 width=800></iframe><br />

12-21-2007, 11:42 PM
works like a charm..

thanks a lot!