Expekt bonuses - Debt Consolidation - Bet365 bonus - Lingerie - Air Jordans

PDA

View Full Version : Search phrases on page


blue_angel
May 9th 2009, 3:19 pm
I have a page and I want to search for some words.
and display relevant messages

I used the following for the title
Example1
var sentence=document.title;
if (sentence.indexOf("Hello")!=-1)
document.writeln ("Hello world");

and I am looking for the body

I tried to use
<script type="text/javascript">
var str=document.body;
document.write(str.search(/w3schools/i));

</script>



even and paid help please :confused:

JavaScriptBank.com
May 9th 2009, 6:25 pm
some JavaScripts for searching, find and replace (http://www.javascriptbank.com/javascript/utility/search-code/) from my site

Hope they're useful

hiteklife
May 10th 2009, 1:27 am
Hi blue_angel! I think I know what you're after.

Try replacing:
var str=document.body;

With:
var str=document.body.innerHTML;

and see if that works. innerHTML is a really handy piece of code. Works on div/span/p... pretty much anything you can think of actually! Let me know if this helps :)

blue_angel
May 10th 2009, 12:35 pm
Thanks all for their reply you helped me a alot
THANK YOU ALL

dimitar christoff
May 11th 2009, 6:19 am
just make sure your js code is outside of the body tag else it will find itself :)