PDA

View Full Version : Jump to search result...


rudybob77
01-11-2008, 08:41 PM
I am creating a Javascript version of this search that will be on a CD. When I click on a search result I want it to direct me to the spot on the page where the result is found(instead of what it does now, which is just brings me to the top of the page)... how can I make it do this? Any help would be much appreciated.

Thanks!

wrensoft
01-11-2008, 09:29 PM
Assuming your pages are HTML pages, see the jump and hightlight script (http://www.wrensoft.com/zoom/support/highlighting.html).

rudybob77
01-11-2008, 09:36 PM
Thanks, I guess I should have read the FAQ huh? :) I actually did get it figured out! But now I have ANOTHER problem.

The pages that are being searched already have a javascript in them that makes a "return to top" button float up and down the page as it is being scrolled. When I go to the pages through the "search results page" the highlight.js must be canceling that script... any ideas on how to work around that? Thanks in advance for your help!

wrensoft
01-11-2008, 10:18 PM
Javascripts interfering with each other are fairly common. There is a troubleshooting page (http://www.wrensoft.com/zoom/support/faq_highlight.html) here.

Do you really need a floating "return to top" button. The "Home" and "End" keys on the keyboard do this job just fine in Firefox and IE.

rudybob77
01-12-2008, 04:18 PM
Unfortunately I do need a "return to top" button. The client I am doing this for is really anal and HAS to have it. Plus, this is a CD that will be packaged with a book and I am sure a lot of the users wont know they can hit the home key.

rudybob77
01-14-2008, 04:13 PM
I went through the troubleshooting and still cannot get this to work. Here is my code... thanks again for the help.



<HTML>
<HEAD>
<!-- TemplateBeginEditable name="doctitle" -->
<TITLE>This is a test</TITLE>
<!-- TemplateEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<!-- Search highlight code //-->
<script type="text/JavaScript" src="../highlight.js"></script>
<style type="text/css">.highlight { background: #FFFF40; }</style>


</HEAD>

<body onload="highlight();">


<center>
Content
</center>



<!-- Begin Floater Code //-->
<script>

// Insert the entire script just before the </div></body> tag.
// Set the following two position parameters
// Negative numbers are relative to right (hX) or bottom (vY)
// Positive numbers are relative to left (hX) or (vY) top
// Experiment with values to get positioning exact, and allow
// for the dimensions of the image & form in the positioning

var hX = 750;
var vY = -80;

</script>

<!-- Edit the HTML between the div tags to suit your design //-->
</p>
<div id="FloatMail" style="position: absolute;
width: 13px;">
<center>
<a href="#"></a>
<a href="#"><img src="../images/top.png" width="29" height="18" border="0"></a>
</center>
</div>


<!-- End of editable HTML //-->

<script>
/* Caution! Do not allow linebreaks other than where shown */
var good;function checkEmailAddress(field){
var goodEmail=field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.go v)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail){good = true}else{alert('Please enter a valid e-mail address.');
field.focus();field.select();good=false;}}
u=window.location;m="I thought this might interest you...";
function mailThisUrl(){good=false;
checkEmailAddress(document.eMailer.address);
if (good){window.location="mailto:"+document.eMailer.address.value+"?subject="+m+"&body="+document.title+" "+u;}}
var nn=(navigator.appName.indexOf("Netscape")!=-1);
var dD=document,dH=dD.html,dB=dD.body,px=dD.layers?'': 'px';
function floatMail(iX,iY,id){
var L=dD.getElementById?dD.getElementById(id):dD.all?d D.all[id]:dD.layers[id];
this[id+'O']=L;if(dD.layers)L.style=L;L.nX=L.iX=iX;L.nY=L.iY=i Y;
L.P=function(x,y){this.style.left=x+px;this.style. top=y+px;};L.Fm=function(){var pX, pY;
pX=(this.iX >=0)?0:nn?innerWidth:nn&&dH.clientWidth?dH.clientWidth:dB.clientWidth;
pY=nn?pageYOffset:nn&&dH.scrollTop?dH.scrollTop:dB.scrollTop;
if(this.iY<0)pY+=nn?innerHeight:nn&&dH.clientHeight?dH.clientHeight:dB.clientHeight;
this.nX+=.1*(pX+this.iX-this.nX);this.nY+=.1*(pY+this.iY-this.nY);this.P(this.nX,this.nY);
setTimeout(this.id+'O.Fm()',33);};
return L;}
floatMail(hX,vY,'FloatMail').Fm();
</script>

<!-- End FloatMail Code //-->




</body></html>

Ray
01-14-2008, 11:25 PM
Did you try the alternative method of calling the highlight() function as described on the support page (http://www.wrensoft.com/zoom/support/faq_highlight.html)?


An alternative to the above method of calling "highlight()" in the onload attribute, would be to call the highlight function after the </body> tag on the page, as follows:
... rest of page here. This is the bottom of the webpage.
</body>
<script type="text/javascript">highlight();</script>
</html>

rudybob77
01-15-2008, 02:07 PM
Yea, I have tried that and it doesn't work either. I'm in a pickle. :(

Ray
01-15-2008, 11:47 PM
Send us an e-mail (http://www.wrensoft.com/contactus.html) and we can provide you with a beta copy of the new highlight script we are working on. It may be more compatible with your "Return to Top" Javascript.

rudybob77
01-16-2008, 03:28 PM
Send us an e-mail (http://www.wrensoft.com/contactus.html) and we can provide you with a beta copy of the new highlight script we are working on. It may be more compatible with your "Return to Top" Javascript.

Thanks, I just sent you an email.

Many Thanks!