Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

multisite search script not working.....urgent

Posted on 2006-11-08
11
Medium Priority
?
206 Views
Last Modified: 2010-04-06
this is multisitesearch script that i have. and i've added some extra iframes into it. the iframe that i added are appering in the webpage but when doing a search only the first two iframes are refreshing and giving me the search that i wanted.the other two iframes are not refreshing and giving any result. what is wrong here?

<head>
<script type="text/javascript">
function handlelink(obj, frameid){
var search, url, addon="";
search=document.forms.form1.In1.value.split(" ");
for (i=0; i<search.length-1; i++) addon=addon+search[i]+"+"
addon=addon+search[search.length-1]
url=obj.href+addon;
document.getElementById(frameid).src=url;
//window.frames[frame_].src=url;
return false;
}

</script>
</head>
<body onload='document.forms.form1.In1.focus()'>
<li><a id=link1 class="current" href="http://www.google.com/search?q=" onClick="return handlelink(this,'cwindow1')">Google</a></li>
<li><a id=link2 href="http://search.yahoo.com/search?p=" onClick="return handlelink(this,'cwindow2')">Yahoo</a></li>
<li><a id=link3 href="http://www.google.com/search?q=" onClick="return handlelink(this,'cwindow3')">Google</a></li>
<li><a id=link4 href="http://search.yahoo.com/search?p=" onClick="return handlelink(this,'cwindow4')">Yahoo</a></li>
<form name=form1 onsubmit="handlelink(document.getElementById('link1'),'cwindow1'); return handlelink(document.getElementById('link2'),'cwindow2')">
Search query: <input name=In1 value="apples oranges">
<input type=submit name="Search" >
</form>
<iframe name="cwindow1" id="cwindow1" style="border:2px solid black" width=279 height=419 src="http://www.google.com/search"></iframe>
<iframe name="cwindow2" id="cwindow2" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
<iframe name="cwindow3" id="cwindow3" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
<iframe name="cwindow4" id="cwindow4" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>




0
Comment
Question by:arasuworld
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 2

Expert Comment

by:bowen18
ID: 17901258
Looks like you didn't add the other two frames on the submit:

<form name=form1 onsubmit="handlelink(document.getElementById('link1'),'cwindow1'); return handlelink(document.getElementById('link2'),'cwindow2')">

Plus you have unneeded ) after the two link names.  The following should work:

<form name=form1 onsubmit="handlelink(document.getElementById('link1','cwindow1'); return handlelink(document.getElementById('link2','cwindow2'); return handlelink(document.getElementById('link3','cwindow3'); return handlelink(document.getElementById('link4','cwindow4')">
0
 
LVL 2

Expert Comment

by:bowen18
ID: 17901327
I apologize, my previous post is incorrect.

This should be the correct line:

<form name=form1 onsubmit="handlelink(document.getElementById('link1'),'cwindow1'); handlelink(document.getElementById('link2'),'cwindow2'); handlelink(document.getElementById('link3'),'cwindow3'); return handlelink(document.getElementById('link4'),'cwindow4')">
0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 2000 total points
ID: 17905212
<head>
<script type="text/javascript">
function handlelink(obj, frameid){
  var search, url, addon="";
  search=document.forms.form1.In1.value.replace(' ','+')
  url=obj.href+search;
  document.getElementById(frameid).src=url;
  return false; // disallow the href
}

function handleLinks() {
  for (var i=1;i<=4;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);
  return false;
}
</script>
</head>
<body onload='document.forms.form1.In1.focus()'>
<li><a id=link1 target="cwindow1" class="current" href="http://www.google.com/search?q=" onClick="return handlelink(this,this.target)">Google</a></li>
<li><a id=link2 target="cwindow2" href="http://search.yahoo.com/search?p=" onClick="return handlelink(this,this.target)">Yahoo</a></li>
<li><a id=link3 target="cwindow3" href="http://www.google.com/search?q=" onClick="return handlelink(this,this.target)">Google</a></li>
<li><a id=link4 target="cwindow4" href="http://search.yahoo.com/search?p=" onClick="return handlelink(this,this.target)">Yahoo</a></li>

<form name=form1
onsubmit="return handleLinks(this)">Search query: <input name=In1 value="apples oranges">
<input type=submit name="Search" >
</form>
<iframe name="cwindow1" id="cwindow1" style="border:2px solid black" width=279 height=419 src="http://www.google.com/search"></iframe>
<iframe name="cwindow2" id="cwindow2" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
<iframe name="cwindow3" id="cwindow3" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
<iframe name="cwindow4" id="cwindow4" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:arasuworld
ID: 17907830
i had the first script working on 2 iframes. but when i try to add 3rd and 4th the iframe, its appearing in webpage but no search result. the script that bowen18 and mplugjan gave works on the 3rd and 4th iframe. so when i try to add 5th and 6th iframe in mplugjan's script the same problem appears. the 5th and 6th iframe appearing but not responding to query. so if i want 5th iframe or 6th iframe (or any number of iframes) where should add or modify the script?
0
 
LVL 2

Expert Comment

by:bowen18
ID: 17907868
If you want to add a 5th, 6th, 7th, etc., you would simply need to change number 4 in mplungjan's script on this line:

for (var i=1;i<=4;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);

To:

for (var i=1;i<=5;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);
or
for (var i=1;i<=6;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);
or
for (var i=1;i<=7;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);

It just depends on how many searches you want to add.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 17910168
change

function handleLinks() {
  for (var i=1;i<=4;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);
  return false;
}
to

function handleLinks() {
  var iFrames = document.getElementsByTagName("iframe")
  for (var i=1;i<=iFrames.length;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);
  return false;
}
assuming you only use the iframes for the links
0
 

Author Comment

by:arasuworld
ID: 17922355
function handleLinks() {
  var iFrames = document.getElementsByTagName("iframe")
  for (var i=1;i<=iFrames.length;i++) handlelink(document.getElementById('link'+i),'cwindow'+i);
  return false;
}


the given script "faulty". after i add one more iframe  (and change href to http://en.wikipedia.org/wiki/Special:Search?search=) and begin searching,  the result appering in iframe but redirected to wikipedia page after 4 seconds. is it becouse of the the script line  (var i=1;i<=iFrames.length;i++) ?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17922996
no. perhaps a script in the page of wiki.
0
 

Author Comment

by:arasuworld
ID: 17924216
follow up question.so how do i make a wikipedia search in a iframe without the site redirecting?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17924659
I will have a look...

BTW you split points between me and me :)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17924693
Here - no way to load wikipedia's homepage without hitting this framebuster:

view-source:http://en.wikipedia.org//skins-1.5/common/wikibits.js?24

// Un-trap us from framesets
if (window.top != window)
      window.top.location = window.location;

Here is a solution


<head>
<script type="text/javascript">
function handlelink(obj, target){
  var search, url;
  search=document.forms[0].In1.value.replace(' ','+')
  url=obj.href+search;
  alert(url+':'+target)
  window.open(url,target);
  return false; // disallow the href
}


function handleLinks() {
  var iFrames = document.getElementsByTagName("iframe")
  for (var i=1;i<=iFrames.length;i++) {
    var link = document.getElementById('link'+i)
    var target=document.getElementById('link'+i).target;
    handlelink(link,target);
  }    
  return false;
}
</script>
</head>
<body onload='document.forms.form1.In1.focus()'>
<li><a id=link1 target="cwindow1" class="current" href="http://www.google.com/search?q=" onClick="return handlelink(this,this.target)">Google</a></li>
<li><a id=link2 target="cwindow2" href="http://search.yahoo.com/search?p=" onClick="return handlelink(this,this.target)">Yahoo</a></li>
<li><a id=link3 target="cwindow3" href="http://www.google.com/search?q=" onClick="return handlelink(this,this.target)">Google</a></li>
<li><a id=link4 target="cwindow4" href="http://search.yahoo.com/search?p=" onClick="return handlelink(this,this.target)">Yahoo</a></li>
<li><a id=link5 target="WIKI" href="http://en.wikipedia.org/wiki/Special:Search?search=" onClick="return handlelink(this,this.target)">Wikipedia</a></li>
 

<form name=form1
onsubmit="return handleLinks(this)">Search query: <input name=In1 value="apples oranges">
<input type=submit name="Search" >
</form>
<iframe name="cwindow1" id="cwindow1" style="border:2px solid black" width=279 height=419 src="http://www.google.com/search"></iframe>
<iframe name="cwindow2" id="cwindow2" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
<iframe name="cwindow3" id="cwindow3" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
<iframe name="cwindow4" id="cwindow4" style="border:2px solid black" width=279 height=419 src="http://search.yahoo.com/"></iframe>
<iframe name="cwindow5" id="cwindow4" style="border:2px solid black" width=279 height=419 src="javascript:'Wikipedia breaks my frames'"></iframe>
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to count occurrences of each item in an array.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question