PDA

View Full Version : <iframe> search problem



sgie23
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

http://testpad.50webs.com

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.. :)

jscheuer1
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">
<head>
<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;
</script>
</head>
<body>
<form action="http://google.com/search" target="googleFrame">
Search : <input id="q" name="q"><input type="submit"><br>
</form>
<iframe name="googleFrame" id="googleFrame" height=500 width=800></iframe><br />
</body>
</html>

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

thanks a lot!