PDA

View Full Version : Find string on page problem



aidanf22
Mar 8th, 2008, 08:03 PM
Hi Guys,
I am a newbie to javascipt so hopefully I can easily communicate my problem to you all.

Below I have included some simple code that finds a specified string on a page.
Fairly simple looking, creates a new TextRange() object with the text contained by the body.
findText() and select() methods are then used to located the string...easy!!


<html>
<head>
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
<script language="JavaScript">
function function1()
{
var q = document.body.createTextRange();
q.findText("here");
q.select();
}
</script>
</head>
<body>


<input type="button"
value="Find"
onClick="function1();">

<h1>heading1</h1>
<h1>here</h1>
<p>here</p>
</body>
</html>


My problem is not really with the code itself, its the fact that I cannot implement this in Internet Explorer Mobile.
Looking at the IE mobile documentation (http://msdn2.microsoft.com/en-us/library/bb415428.aspx) its clear that it has diminished functionality (compared to IE) with regard to scripting, thus it does not contain the createTextRange() method.

I was hoping someone may have some idea of how to go about implementing the above code in IE mobile (if even possible).

Thanks for your help,
Aidan