How to find javascript function in the sharepoint advanced search webpart

Posted on 2009-12-21
Last Modified: 2012-05-08
: I want to include my javascript function in one of the advanced search webpart's java script functions but I cannot find them. When I do page view source I see lot of Javascript rendered in the page. Where that javascript functions are coming for example one of the function by name
ReSetPageHashcode() javascript function but I cannot find in advance.aspx or advancepagelayout.aspx.
Any ideas please...

Note: The webpart is out of box sharepoint webpart.
Question by:vmandem
    LVL 3

    Expert Comment

    Install "JSView" addon in Firefox
    then open you URL in firefox,

    This add-on will show all javascripts separately. and you can find your function easily


    Author Comment

    It is not the question of finding the javascript function seperatly on a page but where those javascript functions are coming from and rendered on that page.
    LVL 26

    Accepted Solution

    A lot of that javascript is emitted by ASP.NET and SharePoint controls.  You can register your own javascript code on a page.  
    See the attached snippet for an example of how to emit javascript.  Depending on where you put this in your code, you can have the script registered on the first load of the page or on postback.  
    Mike Sharp

    // create a string to hold the javascript
    string embedClientScript = "<script>alert('it worked!');</script>";
    string clientScriptKey = "UniqueName";
    // This works, but is obsolete
    // First check to see if the javascript block has already been registered.
    if (!Page.IsClientScriptBlockRegistered(clientScriptKey))
    	Page.RegisterClientScriptBlock(OpenScriptKey, embedClientScript);
    // This is the current implementation
    ClientScriptManager script = Page.ClientScript;
    if (!script.IsClientScriptBlockRegistered(this.GetType(), clientScriptKey))
    	script.RegisterClientScriptBlock(this.GetType(), clientScriptKey, embedClientScript);

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now