Hi,
I'm trying to find a way to look for a certain text to appear on a site. If the text appears, a popup comes up and alerts the users. If the text is not found, it doesn't do anything.
I did a little research and found that it probably could be done with PHP, but with the sheer amounts of "refreshing" this script might have, I thought it'd be better if it didn't trigger a trip to the server every time.
I did a little research, and saw that I could probably use the window.find method to use this.
The window is on another site, so I was thinking of using an invisible iframe for this, and placing it on there. I'm not sure if the javascript would search through the iframe though.
I found this simple little search code on google:
Code:
<head>
<script type="text/javascript">
function FindNext () {
var str = document.getElementById ("findInput").value;
if (str == "") {
alert ("Please enter some text to search!");
return;
}
if (window.find) { // Firefox, Google Chrome, Safari
var found = window.find (str);
if (!found) {
alert ("The following text was not found:\n" + str);
}
}
else {
alert ("Your browser does not support this example!");
}
}
</script>
</head>
<body>
<div>LaLa, Lala, laLa , lala, lalala, tralala, some other text</div>
<br />
<input type="text" id="findInput" value="lala" size="20" />
<button onclick="FindNext ();">Find Next</button>
</body>
and I was thinking of turning it to:
Code:
<head>
<script type="text/javascript">
function FindNext ()
var str;
str="blahblah";
if (window.find) { // Firefox, Google Chrome, Safari
var found = window.find (str);
if (!found) {
alert ("The following text was not found:\n" + str);
}
}
else {
alert ("Text not found!");
}
}
</script>
</head>
<body>
<div>LaLa, Lala, laLa , lala, lalala, tralala, some other text</div>
<br />
<input type="text" id="findInput" value="lala" size="20" />
<button onclick="FindNext ();">Find Next</button>
</body>
What would I need to change, as I'm not familiar with javascript and have an instinct that the above code has an error with it.
Thanks,