Skip to main content
ExLibris
  • Subscribe by RSS
  • Ex Libris Knowledge Center

    Embedding a Primo Search Box

    Primo allows you to add a Primo Search box to any local Web page by embedding Primo’s Brief Search deep link in an HTML form.
    Brief Search Box Embedded in an HTML File
    For more information on Brief Search deep links, see Brief Search Deep Link in the Ex Libris Developer Network.
    To embed a Primo Search box in an HTML file:
    1. Embed the following link in a <form> element of any HTML file:
      http://FE_hostname:port/primo_library/libweb/action/dlSearch.do?
      The following example embeds a simple Search box that will display the Primo results on the same page:

      <script type="text/javascript">
            function searchPrimo() {
                   document.getElementById("primoQuery").value = "any,contains," + document.getElementById("primoQueryTemp").value;
                   document.forms["searchForm"].submit();
            }
            
            function searchKeyPress(e) {
                  if (typeof e == 'undefined' && window.event) {
                        e = window.event;
                  }
                  if (e.keyCode == 13) {
                        document.getElementById('go').click();
                  }
            }
      </script>

      <p><b>Search for</b></p>
      <form name="searchForm" role="search" method="get" action="http://<FE_Hostname>:<FE_port>/primo_library/libweb/action/dlSearch.do" enctype="application/x-www-form-urlencoded; charset=utf-8" id="simple" target="_self"  onsubmit="searchPrimo()">
          <input name="institution" value="<inst_code>" type="hidden">
          <input name="vid" value="<view_code>" type="hidden">    
          <input type="hidden" id="primoQuery" name="query" />
          <input type="text" size="25" id="primoQueryTemp" value=" " name="queryTemp" onkeypress="return searchPrimoEvent(event);" />
          <input id="go" type="button" value="Search" title="Search" onclick="searchPrimo();" alt="Search">
      </form>

      The above example includes the institution, vid, and query input parameters, which are required for a Brief Search deep link.
    2. To customize the embedded search box, append additional parameters to the <form> element using the following format:
      <input name="<parameter_name>" value="<parameter_value>" type="hidden">
      For more information on each parameter, see Brief Search Deep Link in the Ex Libris Developer Network.