title: using javascript in c# not working
body: <p>I am having trouble using a javascript function in my wp7 application. I am essentially attempting to create a Find on Page button like seen in the default IE browser on Windows Phone. So far I have referenced a javascript function from <a href="http://www.liveside.net/2011/10/21/tip-how-to-get-forward-and-find-on-page-back-in-ie9-mobile-on-windows-phone-7-5/" rel="nofollow">http://www.liveside.net/2011/10/21/tip-how-to-get-forward-and-find-on-page-back-in-ie9-mobile-on-windows-phone-7-5/</a> Find on Page option which will be accessed via a click event. my implementation is below which shows the Find on Page search bar as shown in the above link but nothing else happens, only the searchbar is shown and cannot be used. Any ideas on how to properly use this javascript function through my click event? Thanks in advance!</p>
  
  <p>Javascript</p>
  
  <pre><code>javascript:(
  function()
  {
      function G()
      {
          var pf=doc.getElementById('pf');
          var qt=doc.getElementById('qt');
  
          if(null==pf)
          {
              pf=doc.createElement('div');
              pf.id='pf';
              var s=pf.style;
              s.position='absolute';
              s.zIndex='99';
              s.top=(scT||scBT)+'px';
              s.left=(scL||scBL)+'px';
              s.width='100%';
              s.backgroundColor='#FFFF00';
              pf.appendChild(doc.createTextNode('Search: '));
              qt=doc.createElement('input');
              qt.id='qt';
              qt.type='text';
              pf.appendChild(qt);
              var sb=doc.createElement('input');
              sb.type='button';
              sb.value='Find';
              sb.onclick=function()
              {
                  P(qt.value)
              };
              pf.appendChild(sb);
              doc.body.appendChild(pf);
          }
          else
          {
              pf.style.display='inline';
              count=0;
          }
      }
  function P(s)
      {
          document.getElementById('pf').style.display='none';
          if(s==='')
              return;
          var n=srchNode(document.body,s.toUpperCase(),s.length);
          alert("Found "+count+" occurrence"+(count==1?"":"s")+" of '"+s+"'.");
          pf.parentNode.removeChild(pf);
          return n;
      }
  function srchNode(node,te,len)
      {
          var pos,skip,spannode,middlebit,endbit,middleclone;
          skip=0;
          if(node.nodeType==3)
          {
              pos=node.data.toUpperCase().indexOf(te);
              if(pos&gt;=0)
              {
                  spannode=document.createElement("SPAN");
                  spannode.style.backgroundColor="red";
                  middlebit=node.splitText(pos);
                  endbit=middlebit.splitText(len);
                  middleclone=middlebit.cloneNode(true);
                  spannode.appendChild(middleclone);
                  middlebit.parentNode.replaceChild(spannode,middlebit);
                  ++count;
                  skip=1;
              }
          }
          else
          {
              if(node.nodeType==1&amp;&amp;node.childNodes&amp;&amp;node.tagName.toUpperCase()!="SCRIPT"&amp;&amp;node.tagName.toUpperCase!="STYLE")
          {
              for(var child=0;child&lt;node.childNodes.length;++child)
              {
                  child=child+srchNode(node.childNodes[child],te,len);
              }
          }
      }
      return skip;
  }
  var count=0,scL=0,scT=0,scBL=0,scBT=0;
  var w=window,doc=document;
  if(typeof doc.body!='undefined'&amp;&amp;typeof doc.body.scrollLeft!='undefined')
  {
      scBL=doc.body.scrollLeft;
      scBT=doc.body.scrollTop;
  }
  if(typeof doc.documentElement!='undefined'&amp;&amp;typeof doc.documentElement.scrollLeft!='undefined')
  {
      scL=doc.documentElement.scrollLeft;
      scT=doc.documentElement.scrollTop;
  }
  G();
  })()
  </code></pre>
  
  <p>Click Event</p>
  
  <pre><code>public void FindOnPage()
      {
          var resource = Application.GetResourceStream(new Uri("Resources/FindOnPage.txt", UriKind.Relative));
          string text;
          StreamReader sr = new StreamReader(resource.Stream);
  
          while((text = sr.ReadToEnd()) != null)
          {
              TheWebBrowser.InvokeScript("eval", text);
          }        
      }
  </code></pre>
  
  <p>Note, the javascript function is placed in the text file FindOnPage.txt.</p>