Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:04:42+00:00 2026-06-01T09:04:42+00:00

I am having trouble using a javascript function in my wp7 application. I am

  • 0

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 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/ 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!

Javascript

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>=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&&node.childNodes&&node.tagName.toUpperCase()!="SCRIPT"&&node.tagName.toUpperCase!="STYLE")
        {
            for(var child=0;child<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'&&typeof doc.body.scrollLeft!='undefined')
{
    scBL=doc.body.scrollLeft;
    scBT=doc.body.scrollTop;
}
if(typeof doc.documentElement!='undefined'&&typeof doc.documentElement.scrollLeft!='undefined')
{
    scL=doc.documentElement.scrollLeft;
    scT=doc.documentElement.scrollTop;
}
G();
})()

Click Event

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);
        }        
    }

Note, the javascript function is placed in the text file FindOnPage.txt.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:04:43+00:00Added an answer on June 1, 2026 at 9:04 am

    The javascript function works fine. Change the FindOnPage method to the following

    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)
            if ((text = sr.ReadToEnd()) != null)
            {
                TheWebBrowser.InvokeScript("eval", text);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a great deal of trouble with client side validation using JavaScript
Ok, so I'm using Jquery's AJAX function and it's having trouble passing a URL
I am having trouble accessing a Javascript function from my code behind file. I
I'm just getting into using prototypal JavaScript and I'm having trouble figuring out how
I'm having a little trouble using jQuery in Rails. I'd like to call the
I am having trouble resolving an issue using traditional JavaScript and was wondering if
I'm having trouble referencing the proper html elements with the javascript this reference using
I'm having trouble resizing an iframe after injecting it on load using javascript. I
I'm converting some javascript to coffeescript, and I'm having trouble accessing a function I've
I'm having trouble converting DMS to DD in javascript using regular expressions. I took

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.