Search between two sites

Brody

New Member
Hi guys, does any one know if it is possible to set up a search box on one website that, once submitted, can automatically redirect a visitor to another website to display the search results?

Thanks in advance guys!
 

leroy30

New Member
Certainly.

How does the search work on the second website? Do you own or have priviledge access to the second website?

You could, for example, make the search on website two work from keywords in the query string so when you link from website 1 you just copy the keywords in to the link address.

Here's an example:
http://www.google.co.nz/#hl=en&source=hp&biw=1276&bih=868&q=Querystring+keywords&aq=f&aqi=g10&aql=&oq=&fp=3ed9f6fff176994b

Notice how in the link there is a querystring variable 'q' that has a valuye of 'Querystring+keywords'. This would be the simplest setup in my opinion.
 

Brody

New Member
Hi leroy30, thanks for replying, very much appreciated!

I do have permission to use both sites, i'm trying to put a search box on a fan page that redirects the visitor to the main website to display the search results.

Here's the fan page:

http://www.facebook.com/WickedGadget?sk=app_189786571060070

Here's the website I'm trying to redirect to:

http://www.wickedgadget.com

Here's the code I'm using for the search box on the fan page, it now includes the 'Query+keywords' but unfortunately this didn't work:

<form action="http://www.wickedgadget.com/search,b.html?q=Query+keywords" method="post" target="_blank" >
<input type="text" class="box" /><br /><br />
<input name="submit" type="image" src="images/send.jpg" />
<br /><br />
</form>

I'd greatly appreciate it if you could tell me where I'm going wrong!
 

Brody

New Member
Is there anyone that can point me in the right direction with this? I would appreciate it hugely.
 

leroy30

New Member
Make your button a link... You're trying to post back to that page (i think, by the looks of it) but it probably won't let you do that.

Make a link or a javascript button to redirect to that url. For example...

<input id="search" type="text" class="box" />
<div class="button" onclick="searchredirect();"></div>

<script type="text/javascript">

function searchredirect() {

location.href = "http://www.wickedgadget.com/search,b.html?q=" + document.getElementById('search').value;

};

</script>
 

Brody

New Member
Thanks again leroy30, your help has got me very close to achieving the desired result, I really appreciate your help.

It all works just the way I want but I just need the new page to open in a new window rather than in the fan page iframe. Is this possible at all?

Thanks again, you've been really helpful!
 

Brody

New Member
Hi Leroy30, just to keep you updated, I have now added window.parent. to the beginning of location.href so it says:

window.parent.location.href = "http://www.wickedgadget.com/search,b.html?q=" + document.getElementById('search').value;

So it now opens in the same window. This is a good temporary fix but is it possible to have it open in a new window? using 'blank' in the place of 'parent' doesnt seem to work.
 

DHDdirect

New Member
Look at THIS site for information about opening a new window with javascript. Be careful though because some methods trigger popup blockers.

Hope that helps.
 
Last edited:

Brody

New Member
Thanks for that, I found that site on my travels earlier, I'm a complete noob in javascript and I couldn't figure out how to have two onclick functions going at the same time, one seemed to cancel out the other.
 

DHDdirect

New Member
Sorry Brody, I should have been more clear. It's the window.open() method that you want to focus on. It states that a new window will open where the window.parent is obviously in the same browsing window.

THIS will explain all it's attributes.
 

Brody

New Member
Thanks for your help, it is much appreciated. I still don't quite know what I'm doing but it's about time I got to grips with javascript so I'll have to go through the w3schools course so I don't have to ask dumb questions in forums! Thanks again for your help.
 

DHDdirect

New Member
You're welcome.. they are certainly not dumb questions. It's continuous learning for all of us and the least we can do is help point you in the correct direction.
 

leroy30

New Member
Thanks for quoting me, SundayForever - but you forgot the quotes! :p

As DHDdirect said be careful about popup blockers if you are opening in a new window.

Glad we could help! The best way to learn is to try it, see it not working, and find a way to make it working. That way, by the time it is working, you will have tried many different approaches and it'll be more ingrained in your memory than if you did it just once from a tutorial.

Nothing wrong with a good tutorial however :)
 
Top