PDA

View Full Version : search by word?


hughesmi
09-20-2002, 02:36 PM
Is there a way I can just click on a Word, such as Africa and this will send for the serch?



<HTML>
<HEAD>
<TITLE>Embassy Web Site Finder.</TITLE>

<!----------- DO NOT UNDER ANY CIRUCSTANCES CHANGE THESE PATHS ---------------------------->
<script language=JavaScript src="link.js"></script>
<!----------- DO NOT UNDER ANY CIRUCSTANCES CHANGE THESE PATHS ---------------------------->

<base target="_self">

</HEAD>
<BODY BGCOLOR=#336699 TEXT=#FFFFFF LINK=#FFFFFF VLINK=#FFFFFF ALINK=#FFFFFF>
<center>

</center>

<center>
</center>
<p>
<FIELDSET>
<LEGEND><font size="3" face="Tahoma"><b>&nbsp;Search.</b></font></LEGEND>
<p>
<font face="Tahoma"><b>
<font size="2">
<br>
</font>
</b></font>
<hr color="#FFFFFF" size="0">


<form name="searchengine" onSubmit="search()" target="_blank">

<p align="center"><font face="Tahoma">&nbsp; <input type ="text" name ="keywords" value="Enter a Location" onfocus="this.value=''" maxlength=40 size="22" style="text-transform: capitalize; font-weight: bold; border-style: solid; border-color: #FFFF00">&nbsp;
<input type = submit name="go" Value="Find It" onClick="search()" style="border-style: solid; border-color: #FF0000"><input type="reset" value="Reset" name="B1"><br>
</font>

</p>

<p align="center"><center>

<font face="Tahoma" size="2">Africa.</font>

</p>
<p align="center"><font size="2">The Americas
<br>
<br>
East Asia and Pacific
<br>
<br>
Europe-Eurasia
<br>
<br>
Near East and North Africa
<br>
<br>
South Asia</font>
<br>
</p>
<hr color="#ffffff" size="0">
</center>

</form>
</FIELDSET>
<p align="center"><br>
<br>
</p>
</BODY>
</HTML>

:eek: :eek: :mad: :p :o :o

ASAAKI
09-20-2002, 07:26 PM
as far as i know, just clicking on plain text on a page doesn't trigger an event that you can handle. why don't u turn Africa and the other places into links? then u cud have something like:
<a href="#" onclick="your_search_function">Africa</a>
:thumbsup:

Alekz
09-23-2002, 11:22 AM
Hi,
I've seen something similar, but can not find it right now...
If I remember well it used getSelection on the body. Try catching the body.onclick event and check for selection.
It will work when user double clicks a word, because on the second click text is selected before firing the click event. I should also work in NS4.x i suppose...

Alex

Pooh
09-23-2002, 12:02 PM
<script>

var tr;
function colorIt() {
mouseX=event.x;
mouseY=event.y;
tr=document.body.createTextRange();
tr.moveToPoint(mouseX, mouseY);
tr.expand("word");
tr.execCommand("ForeColor",false,"red");
alert(tr.text)}
document.onclick=colorIt;
</script>

You can work that into a search

beetle
09-23-2002, 04:57 PM
Very nice Pooh! I like it, textRanges aren't something that I work with often, it's nice to see a smooth implementation.

:thumbsup: