...

View Full Version : Help with Targets



n0z^
10-13-2006, 03:46 PM
Hi, I have a website which i recently added a search to, i purchased a piece of software to create the search for me to save me time with the indexing. The search its self works fine and all has been ok. Until now i have had the search simply on the side of the site, now i want to put it in an iFrame my problem is that i cannot seem to select a target for the submit button so that it opens in the whole page (_top). I have emailed the company that made the software, they replied explaining how to do this using the software.... doesn't seem to work (either that or im just too stupid to work it out :P).

Here is the code im using for the search:
<FORM name="formSear" action="../search.html" method="GET" onSubmit="return qs();" style="margin-bottom: 0" target="_top">

<script>
function qs(){var f=document.formSear;var qe=f.searWords.value;if(window.encodeURIComponent)qe=encodeURIComponent(qe);if(f.area)if(f.area.valu e==2){document.location="http://www.google.com/search?q="+qe;return false;}var pt=document.location.href;var iq=pt.indexOf('?');if(iq!=-1)pt=pt.substring(0, iq);if(f.action)if(f.action!="")pt=f.action;var ue=pt+"?searWords="+qe;if(f.search)ue+="&search="+f.search.value;if(f.match)ue+="&match="+f.match.value;document.location=ue;return false;}
</script>
<font size="1">
<INPUT name="searWords" style="font-family: Verdana; font-size: 10px" size="16"">
</font>
<INPUT name="Send" type="submit" value="Search" style="font-family: Verdana; font-size: 10px">
</FORM>

Sorry its a bit messy :(
So is there a way that this code can be edited to make it open in the whole page not just in the small iFrame?

Any ideas or help would be really appreciated

Thank you for your time

Daniel Westwater

_Aerospace_Eng_
10-13-2006, 04:32 PM
<FORM name="formSear" action="../search.html" method="GET" onSubmit="return qs();" style="margin-bottom: 0" target="_top">

<script>
function qs(){var f=document.formSear;var qe=f.searWords.value;if(window.encodeURIComponent)qe=encodeURIComponent(qe);if(f.area)if(f.area.valu e==2){document.location="http://www.google.com/search?q="+qe;return false;}var pt=document.location.href;var iq=pt.indexOf('?');if(iq!=-1)pt=pt.substring(0, iq);if(f.action)if(f.action!="")pt=f.action;var ue=pt+"?searWords="+qe;if(f.search)ue+="&search="+f.search.value;if(f.match)ue+="&match="+f.match.va lue;document.location=ue;return false;}
</script>
<font size="1">
<INPUT name="searWords" style="font-family: Verdana; font-size: 10px" size="16"">
</font>
<INPUT name="Send" type="submit" value="Search" style="font-family: Verdana; font-size: 10px">
</FORM>

<FORM name="formSear" action="../search.html" method="GET" onSubmit="return qs();" style="margin-bottom: 0" target="_top">

<script>
function qs(){var f=document.formSear;var qe=f.searWords.value;if(window.encodeURIComponent)qe=encodeURIComponent(qe);if(f.area)if(f.area.valu e==2){parent.frames['youriframename'].location="http://www.google.com/search?q="+qe;return false;}var pt=parent.frames['youriframename'].location.href;var iq=pt.indexOf('?');if(iq!=-1)pt=pt.substring(0, iq);if(f.action)if(f.action!="")pt=f.action;var ue=pt+"?searWords="+qe;if(f.search)ue+="&search="+f.search.value;if(f.match)ue+="&match="+f.match.va lue;document.location=ue;return false;}
</script>
<font size="1">
<INPUT name="searWords" style="font-family: Verdana; font-size: 10px" size="16"">
</font>
<INPUT name="Send" type="submit" value="Search" style="font-family: Verdana; font-size: 10px">
</FORM>
Change the parts in bold to match the parts in bold of the second form. You do know you can get a custom form for your site without using js? http://www.google.com/services/free.html

n0z^
10-13-2006, 04:36 PM
Thanks for you quick reply, i do realise that you can get a google search for free but it includes all the google brand images and ad's i believe and as this is for a company site i do not think it is appropriate

Thanks

n0z^
10-13-2006, 04:50 PM
I have just tryed the code that you supplied, entering in the iFrame name but it doesnt seem to have worked, im sure it must be something that i am doing wrong as i doubt the code you gave me is wrong.
You can look for yourself, the page is...

http://www.etiltd.co.uk/index1.htm
http://www.etiltd.co.uk/frames/sideframe.htm

I know that the code is a mess as the page has been done in frontpage (made before i joined the company :P)
Im sure its just something simple, but i have got to the point of pulling my hair out with this thing! Therfore probably missing a simple mistake.

Thanks

Dan

_Aerospace_Eng_
10-13-2006, 04:54 PM
You need to change it to I1 not I2 and there is one more part you need to change that I missed earlier.

if(f.match)ue+="&match="+f.match.value;document.location=ue;return false;}</script>

if(f.match)ue+="&match="+f.match.value;parent.frames['I1'].location=ue;return false;}</script>

n0z^
10-13-2006, 05:13 PM
Thanks again for another quick reply! I have now done as you have said, problem is that it now opens in the top iFrame. (the one with the banner and navBar in) I really don't mean to be a bother and do feel rude keep replying back when its not working. I am very greatfull for your help so far. The thing is that i want it to open up in the whole page... not in an iFrame. As explained in my first post, the search is in an iFrame but i want the link, like the others on the side bar to open in the whole page.
This would be done in HTML by simply adding [target="_top"] to the link. i have been able to do this also with the dropdown box which caused a few problems but i got there in the end. I thought that getting the search to do the same would be far more simple... how wrong was I :/

Thanks again

Dan

_Aerospace_Eng_
10-13-2006, 05:16 PM
Okay so you want it to open in the iframe next to it where the content is at or you just want it to be its own page? If you want it to be its own page try

parent.location
instead of

parent.frames['youriframename'].location

n0z^
10-13-2006, 05:24 PM
You got it!

I am so greatfull for your help. Stress over! I will be straight over to the nomination page to post how helpfull you have been. Im so glad that you have replyed so quickly as im out of the office in 10mins and it would have meant that the site would have had a dodgy search that didnt work on it all over the weekend, and as the site is very busy and has alot of traffic it probably would have cost a bit in loss of sales!

Just looked at the Nomination page... looks like you have many fans here!

Thank You so very much

Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum