0

I have this javascript code that is supposed to be refreshing a given web page after a specific amount of time and tries to find a certain word after each refresh. And when that word is found, a certain alarming sound is supposed to go off. here's the code:

javascript: var myRegExp = prompt("the word"); timeout = prompt("the time in seconds"); current = location.href; setTimeout('reload()', 1000 * timeout); var audio = new Audio('http://soundbible.com/grab.php?id=2197&type=mp3'); function reload() { var found = searchText(); if (!found) { setTimeout('reload()', 1000 * timeout); fr4me = '<frameset cols=\'*\'>\n<frame id="frame01" src=\'' + current + '\'/>'; fr4me += '</frameset>'; with(document) { write(fr4me); void(close()) }; } } function searchText() { var f = document.getElementById("frame01"); if (f != null && f.contentDocument != null) { var t = f.contentDocument.body.innerHTML; var matchPos = t.search(myRegExp); if (matchPos != -1) { audio.play(); return true; } else { return false; } } }

My question/request is, how to make the alarming sound plays on endless loop when triggered? Answered

And also, how to make the search for the word case insensitive?

1 Answer 1

0

Try doing this:

myAudio = new Audio('yoursound.mp3'); myAudio.addEventListener('ended', function() { this.currentTime = 0; this.play(); }, false); myAudio.play();

Sign up to request clarification or add additional context in comments.

3 Comments

thanks man! is there anyways that you would know how to make the search for the word case insensitive?
@AhmedAlarbi just transform everything to lower case (or upper case) while searching
I don't think you got my question, i just want to make the code look for the word "example" weather it was like this "EXAMPLE", like this "example" or even like this "ExAmPlE"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.