Is any ColdFusion script I can put on my webpage that will create a search bar so people can type keywords to match it on the current page in my website? It will be exactly like the finder search bar that comes with your browser window, IE; click edit, then find on this page, which brings up the search box.
I know that JavaScript can do this. I tried to insert JavaScript to my .cfm page. It doesn't work. Any help will be appreciated.
Here is the JavaScript and Form code I used: - <script>
-
<!-- Hide from old browsers
-
-
/******************************************
-
* Find In Page Script -- Submitted/revised by Alan Koontz (alankoontz@REMOVETHISyahoo.com)
-
* Visit Dynamic Drive (http://www.dynamicdrive.com/) for full source code
-
* This notice must stay intact for use
-
******************************************/
-
-
// revised by Alan Koontz -- May 2003
-
-
var TRange = null;
-
var dupeRange = null;
-
var TestRange = null;
-
var win = null;
-
-
-
// SELECTED BROWSER SNIFFER COMPONENTS DOCUMENTED AT
-
// http://www.mozilla.org/docs/web-deve...wser_type.html
-
-
var nom = navigator.appName.toLowerCase();
-
var agt = navigator.userAgent.toLowerCase();
-
var is_major = parseInt(navigator.appVersion);
-
var is_minor = parseFloat(navigator.appVersion);
-
var is_ie = (agt.indexOf("msie") != -1);
-
var is_ie4up = (is_ie && (is_major >= 4));
-
var is_not_moz = (agt.indexOf('netscape')!=-1)
-
var is_nav = (nom.indexOf('netscape')!=-1);
-
var is_nav4 = (is_nav && (is_major == 4));
-
var is_mac = (agt.indexOf("mac")!=-1);
-
var is_gecko = (agt.indexOf('gecko') != -1);
-
var is_opera = (agt.indexOf("opera") != -1);
-
-
-
// GECKO REVISION
-
-
var is_rev=0
-
if (is_gecko) {
-
temp = agt.split("rv:")
-
is_rev = parseFloat(temp[1])
-
}
-
-
-
// USE THE FOLLOWING VARIABLE TO CONFIGURE FRAMES TO SEARCH
-
// (SELF OR CHILD FRAME)
-
-
// If you want to search another frame, change from "self" to
-
// the name of the target frame:
-
// e.g., var frametosearch = 'main'
-
-
//var frametosearch = 'main';
-
var frametosearch = self;
-
-
-
function search(whichform, whichframe) {
-
-
// TEST FOR IE5 FOR MAC (NO DOCUMENTATION)
-
-
if (is_ie4up && is_mac) return;
-
-
// TEST FOR NAV 6 (NO DOCUMENTATION)
-
-
if (is_gecko && (is_rev <1)) return;
-
-
// TEST FOR Opera (NO DOCUMENTATION)
-
-
if (is_opera) return;
-
-
// INITIALIZATIONS FOR FIND-IN-PAGE SEARCHES
-
-
if(whichform.findthis.value!=null && whichform.findthis.value!='') {
-
-
str = whichform.findthis.value;
-
win = whichframe;
-
var frameval=false;
-
if(win!=self)
-
{
-
-
frameval=true; // this will enable Nav7 to search child frame
-
win = parent.frames[whichframe];
-
-
}
-
-
-
}
-
-
else return; // i.e., no search string was entered
-
-
var strFound;
-
-
// NAVIGATOR 4 SPECIFIC CODE
-
-
if(is_nav4 && (is_minor < 5)) {
-
-
strFound=win.find(str); // case insensitive, forward search by default
-
-
// There are 3 arguments available:
-
// searchString: type string and it's the item to be searched
-
// caseSensitive: boolean -- is search case sensitive?
-
// backwards: boolean --should we also search backwards?
-
// strFound=win.find(str, false, false) is the explicit
-
// version of the above
-
// The Mac version of Nav4 has wrapAround, but
-
// cannot be specified in JS
-
-
-
}
-
-
// NAVIGATOR 7 and Mozilla rev 1+ SPECIFIC CODE (WILL NOT WORK WITH NAVIGATOR 6)
-
-
if (is_gecko && (is_rev >= 1)) {
-
-
if(frameval!=false) win.focus(); // force search in specified child frame
-
strFound=win.find(str, false, false, true, false, frameval, false);
-
-
// The following statement enables reversion of focus
-
// back to the search box after each search event
-
// allowing the user to press the ENTER key instead
-
// of clicking the search button to continue search.
-
// Note: tends to be buggy in Mozilla as of 1.3.1
-
// (see www.mozilla.org) so is excluded from users
-
// of that browser.
-
-
if (is_not_moz) whichform.findthis.focus();
-
-
// There are 7 arguments available:
-
// searchString: type string and it's the item to be searched
-
// caseSensitive: boolean -- is search case sensitive?
-
// backwards: boolean --should we also search backwards?
-
// wrapAround: boolean -- should we wrap the search?
-
// wholeWord: boolean: should we search only for whole words
-
// searchInFrames: boolean -- should we search in frames?
-
// showDialog: boolean -- should we show the Find Dialog?
-
-
-
}
-
-
if (is_ie4up) {
-
-
// EXPLORER-SPECIFIC CODE revised 5/21/03
-
-
if (TRange!=null) {
-
-
TestRange=win.document.body.createTextRange();
-
-
-
-
if (dupeRange.inRange(TestRange)) {
-
-
TRange.collapse(false);
-
strFound=TRange.findText(str);
-
if (strFound) {
-
//the following line added by Mike and Susan Keenan, 7 June 2003
-
win.document.body.scrollTop = win.document.body.scrollTop + TRange.offsetTop;
-
TRange.select();
-
}
-
-
-
}
-
-
else {
-
-
TRange=win.document.body.createTextRange();
-
TRange.collapse(false);
-
strFound=TRange.findText(str);
-
if (strFound) {
-
//the following line added by Mike and Susan Keenan, 7 June 2003
-
win.document.body.scrollTop = TRange.offsetTop;
-
TRange.select();
-
}
-
-
-
-
}
-
}
-
-
if (TRange==null || strFound==0) {
-
TRange=win.document.body.createTextRange();
-
dupeRange = TRange.duplicate();
-
strFound=TRange.findText(str);
-
if (strFound) {
-
//the following line added by Mike and Susan Keenan, 7 June 2003
-
win.document.body.scrollTop = TRange.offsetTop;
-
TRange.select();
-
}
-
-
-
}
-
-
}
-
-
if (!strFound) alert ("String '"+str+"' not found!") // string not found
-
-
-
}
-
// -->
-
</script>
-
[HTML]<form name="form1" onSubmit="searc h(document.form 1, frametosearch); return false"><input type="text" name="findthis" size="15" title="Press 'ALT s' after clicking submit to repeatedly search page"> <input type="submit" value="Find in Page" ACCESSKEY="s"></form>
[/HTML]
Thanks,
YaoBao
5 4551 acoder 16,027
Recognized Expert Moderator MVP
JavaScript is best suited to this task. Does this work on a normal HTML page, i.e. not a Coldfusion file?
JavaScript is best suited to this task. Does this work on a normal HTML page, i.e. not a Coldfusion file?
It is work on normal HTML page. But dosn't work with my Coldfusion file. I jsut insert the JavaScript and the FORM above into my coldfusin file. Maybe I missed some code?
Thanks,
YaoBao
acoder 16,027
Recognized Expert Moderator MVP
Show the full page code. You can snip the JavaScript part.
It works now. I pasted the code to wrong place. Thank you very much tacking time to help me. Thank you again. YaoBao
acoder 16,027
Recognized Expert Moderator MVP
No problem, glad you managed to fix it. Post again if you have any more questions.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Fabrice Labrousse |
last post by:
Hello,
Here is a hard problem i cannot solve about window.opener method
I think you'll need to be a specialist to find the solution... i can't find
the solution by myself ! Please help me.
Here is the problem (quiet complicated to explain).
I use two differents servers with two IIS 4.0 Web servers
On the first one (let's name it Server1) i got my web site. On my web site,
|
by: Anna K. |
last post by:
Hi Experts,
I'm new to JavaScript and web-based apps development, so I'll tell you right off
that I don't really know my way around it as of yet.
I'm trying to create a code library set with JavaScript (in DreamweaverMX)
to display "buttons" with which to select pages in a gallery. I'm trying to
"grey out" (and disable) the button for the current page when it is displayed.
(This isn't rocket science here, but it's something that I...
|
by: Les Juby |
last post by:
I have an excellent search script which provides the visitor with the
searched for text highlighted and positioned within the context of the
preceding and following 10 words.
However, some of the files we then link to are very big (such as a
Parliamentary Act about 30 screens deep) and I'd like to be able to
position that page at the point where the searched for text is first
found.
No problem with passing a variable from the search...
|
by: 28tommy |
last post by:
Hi,
I'm trying to find scripts in html source of a page retrieved from the
web.
I'm trying to use the following rule:
match = re.compile('<script + src=+>')
I'm testing it on a page that includes the following source:
<script language="JavaScript1.2"
|
by: one man army |
last post by:
Hi All-
I am new to PHP. I found FAQTS and the php manual. I am trying this
sequence, but getting 'no zip string found:'... PHP Version 4.4.0
$doc = new DomDocument;
$res = $doc->loadHTMLFile("./aBasicSearchResult.html");
if ( $res == true )
{
$zip = $doc->getElementById('zipRaw_id')->value;
if ( 0 != $zip ) {
| |
by: Joey_Stacks |
last post by:
I've been searching for an example of a javascript rollover effect,
and I'm beginning to think it's impossible, dare I say? Here's what
I'm looking for. It's a double rollover effect. You mouseover an
image and it swaps the image itself, and editable html text in another
location. Here's the catch. The mouseover effect around the image is
created in CSS (table border) so there's no need to use dual images for
on and off states. The...
|
by: amir |
last post by:
Hi,
When compiling a page in VS2005 this morning I received 101 messages
regarding schema problems in my web.config file.
When I go to view an aspx page in my IIS, IE just displays a blank
page.
I have the June Atlas CTP installed.
|
by: emily224 |
last post by:
Hello,
I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer must be embedded somewhere in the source code, and I would like to know if anyone knows where to find the correct answer.
I would greatly appreciate it!!
Thanks!!
<!--put the preloads file here as it must load before the website class...
|
by: emily224 |
last post by:
Hello,
I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer must be embedded somewhere in the source code, and I would like to know if anyone knows where to find the correct answer.
I would greatly appreciate it!!
Thanks!!
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |