title: How to update/overwrite the page title dynamically?
body: <p>I m using an online template in which I removed various things to make my own modifications.
  There are two pages,
  The index page takes a search query as input field and the results page displays the results of on this query.
  Everythying is working fine but due  to the modifications I did, the results page has title as</p>
  
  <p>"undefined - The search results"</p>
  
  <p>This undefined is supposed to display the input string from index page.
  But I want that It should have the title as just "The search results"</p>
  
  <p>What I could do so that it overwrites this title and just has the title I require.</p>
  
  <p>I have tried</p>
  
  <pre><code>document.title = "This is the new page title.";
  </code></pre>
  
  <p>Under the html head as you can see in script.</p>
  
  <p>But after doing so It displays "undefined - This is the new page title. as title.</p>
  
  <p>I want to remove that undefined.</p>
  
  <p>This is the HTML code for results page, if you can find out whats making the title so.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;meta charset=utf-8&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"&gt;
  
          &lt;title&gt;The Search results&lt;/title&gt;
      &lt;meta content="Mamma" name="description"/&gt;
      &lt;meta content="Mamma" name="keywords"/&gt;
      &lt;link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" /&gt; 
  
      &lt;link media="all" rel="stylesheet" href="/static/results/style.css"&gt;
      &lt;!-- Thumbnail--&gt;
      &lt;link media="all" rel="stylesheet" href="/static/component.css"&gt;
      &lt;!-- Thumbnail_End--&gt;
  
      &lt;link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,300,300italic,600' rel='stylesheet' type='text/css'&gt;
  
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;window.jQuery || document.write('&lt;script src="http://mamma.com/static/front/js/jquery-1.8.3.min.js"&gt;&lt;\/script&gt;')&lt;/script&gt;
      &lt;script type="text/javascript" src="http://mamma.com/static/front/js/jquery.main.js"&gt;&lt;/script&gt;
  
  
      &lt;!--&lt;script type="text/javascript" src="http://mamma.com/static/front/js/jquery.cookies.2.2.0.min.js"&gt;&lt;/script&gt;--&gt;
      &lt;script type="text/javascript" src="http://mamma.com/static/front/js/scrolltop.js"&gt;&lt;/script&gt;
  
      &lt;!-- Thumbnail--&gt;
      &lt;script type="text/javascript" src="http://mamma.com/static/front/js/modernizr.js"&gt;&lt;/script&gt;
  
  
      &lt;!--[if IE]&gt;&lt;script type="text/javascript" src="js/ie.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
      &lt;script language="javascript"type="text/javascript"&gt;
  document.title = "This is the new page title.";
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;link media="all" rel="stylesheet" href="http://mamma.com/static/front/css/stylemasonry.css"&gt;
  &lt;script type="text/javascript" src="http://mamma.com/static/front/js/results.js?v=1388742739"&gt;&lt;/script&gt;
  
  
  
  &lt;script type="text/javascript" src="http://mamma.com/static/front/js/common.js"&gt;&lt;/script&gt;
  
  &lt;!-- Make sure jQuery is loaded. Loads Jquery from Google if not loaded by a plugin. --&gt;
  &lt;script type="text/javascript" src="http://mamma.com/static/front/js/jQueryLoader.js"&gt;&lt;/script&gt;
  &lt;!-- SUPERFISH --&gt;
  &lt;script type="text/javascript" src="http://mamma.com/static/front/js/hoverIntent.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://mamma.com/static/front/js/superfish.js"&gt;&lt;/script&gt;
  
  
  &lt;!-- Flexslider --&gt;
  &lt;link media="all" rel="stylesheet" href="http://mamma.com/static/front/css/flexslider.css"&gt;
  &lt;script type="text/javascript" src="http://mamma.com/static/front/js/jquery.flexslider.js"&gt;&lt;/script&gt;
  
  &lt;style id="myStyle"&gt;
      &lt;/style&gt;
  
      &lt;!-- wrapper --&gt;
      &lt;div id="wrapper"&gt;
      &lt;div id="static" size="big"&gt;
        &lt;div id="topspace" style="height: 330px;"&gt;
        &lt;/div&gt;
          &lt;!-- header --&gt;
          &lt;header id="header" class="vcard"&gt;
                      &lt;!-- logo --&gt;
  
  
                      &lt;style type="text/css"&gt;
                      .result_logo{
                          background: url(/static/logos_1.png);
                          background-repeat: no-repeat;
                          /*height: 12px;*/
                          background-size : 100% 100%;
                          float: left;
                          height: 40px;
                          max-width: 230px;
                          width: 230px;
                          cursor: pointer;
                           margin: 0px 3.12% 0 0;
                      }
                      .result_slogo{
                          background: url(http://mamma.com/static/front/images/slogo.png);
                          background-repeat: no-repeat;
                          background-size : 100%;
                          cursor: pointer;
                          height: 42px;
                          margin: 0 22px 0 15px;
                          width: 25px;
                      }
                  &lt;/style&gt;
                      &lt;a href="http://localhost:8080/ms"&gt;&lt;div id="logo" class="result_logo"&gt;&lt;/div&gt;&lt;/a&gt;
                      &lt;a href="http://localhost:8080/ms"&gt;&lt;div id="logo" class="result_slogo"&gt;&lt;/div&gt;&lt;/a&gt;
  
  
  
              &lt;!-- user navigation --&gt;
              &lt;nav class="user-nav"&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;a href="#" class="help"&gt;help&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#" class="settings"&gt;settings&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/nav&gt;
              &lt;style type="text/css"&gt;
              .local_text{
                  flaot:left;
                  border:1px solid red;
              }
              &lt;/style&gt;
              &lt;!-- form search --&gt;
  
  
              &lt;form id="get_value" action="{% url 'diablo:results' %}" class="form-search" method="get"&gt;
                      {% csrf_token %}
                      &lt;fieldset&gt;
                          &lt;input type="text" id="pre_text" name="q" autocomplete="on" value="{{ query }}" class="pre_text"&gt;
                          &lt;!--&lt;input type="text" id="pre_test" name="what" autocomplete="on" value="{{ query }}" class="local_what" 
                          onblur=" if(this.value== '') this.value='What?';" onfocus=" if(this.value=='What?') this.value=''; "
                          value="What?" style="display: none;" &gt; 
  
                          &lt;input type="text" id="pre_where" name="where" autocomplete="on" class="local_where" 
                          onblur=" if(this.value== '') this.value='Where?';" onfocus=" if(this.value=='Where?') this.value=''; "
                          value="" style="display: none;"&gt;
                          --&gt;
  
                          &lt;input type="submit" id="search" value="search"&gt;
  
                      &lt;/fieldset&gt;
                  &lt;/form&gt;
  
              &lt;div style="clear:both"&gt;&lt;/div&gt;
  
          &lt;/header&gt;
  
      &lt;/div&gt;
  
          &lt;!-- twocolumns --&gt;
  
  
          &lt;div id="twocolumns"&gt;
              &lt;!-- aside --&gt;
              &lt;div class="aside"&gt;
                  &lt;!-- search areas --&gt;
                  &lt;!--&lt;div class="search-areas"&gt;
  
                  &lt;a href="#" class="opener"&gt;&lt;span&gt;Web&lt;/span&gt;&lt;/a&gt;
                      &lt;div class="drop"&gt;
                          &lt;strong class="title"&gt;Search areas:&lt;/strong&gt;
                          &lt;ul&gt;--&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
                              &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
                              &lt;!--
                                &lt;li  class="active"&gt;&lt;a class="we" href="javascript:void(0);"&gt;Web&lt;/a&gt;&lt;/li&gt;
  
                               &lt;li &gt;&lt;a class="we" href="javascript:void(0);"&gt;News&lt;/a&gt;&lt;/li&gt;
  
                               &lt;li &gt;&lt;a class="we" href="javascript:void(0);"&gt;Images&lt;/a&gt;&lt;/li&gt;
  
                               &lt;li &gt;&lt;a class="we" href="javascript:void(0);"&gt;Videos&lt;/a&gt;&lt;/li&gt;
  
                                &lt;li &gt;&lt;a class="we" href="javascript:void(0);"&gt;Local&lt;/a&gt;&lt;/li&gt;
                          &lt;/ul&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;--&gt;
  
  
              &lt;/div&gt;
              &lt;div class="holder"&gt;
                  &lt;!-- search tabs--&gt;
                  &lt;!--&lt;div id="prev_next"&gt;
                      &lt;div class="small_screen_prev"&gt;
                          &lt;div id="prev" style="display:none;"&gt; &lt;img src="http://mamma.com/static/front/images/prev_arrow.png" alt="" /&gt;&lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="search-tabs"&gt; 
                          &lt;a href="#" class="opener"&gt;search tabs&lt;/a&gt;
                          &lt;div class="drop"&gt; &lt;strong class="title"&gt;Search tabs:&lt;/strong&gt;
                              &lt;div id="tab"&gt;
                                  &lt;ul&gt;&lt;/ul&gt;
                              &lt;/div&gt;
                              &lt;div style="clear:both"&gt;&lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="small_screen_next"&gt;
                          &lt;div id="next" style="display:none;"&gt;&lt;img src="http://mamma.com/static/front/images/next_arrow.png" alt="" /&gt;&lt;/div&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;--&gt;
                  &lt;!-- search content --&gt;
                   &lt;section class="search-content tab-content" id="mamma_tab_content"&gt;
  
                  &lt;h2 style="color:#888; font-size: 150%; margin:20px 0 20px 20px; overflow:hidden;float:left"&gt;
                      Meta Search Engine Results
                  &lt;/h2&gt;&lt;br&gt;{% load customfilter %}
                  {% for a in r %}
                  &lt;div id="org_section_id_20140421181147" class="results-only" style="margin:0 0 0 20px;overflow:hidden;float:left"&gt;
                   &lt;div class="midresult" id="main20140421181147"&gt;
                      &lt;h3&gt;
                          &lt;a href="{{ a.0 }}"&gt;{{ a.1.title|safe }}&lt;/a&gt;
                      &lt;/h3&gt;   
                      &lt;h4&gt; 
                          &lt;a href="{{ a.0 }}"&gt;{{ a.0 }}&lt;/a&gt;
                      &lt;/h4&gt;
                  &lt;p&gt;{{ a.1.desc|safe }}&lt;br/&gt;&lt;br/&gt;&lt;font size=5 color="green"&gt;Google Rank: {{ a.1.GRank|actualRank }} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Yahoo Rank: {{ a.1.YRank|actualRank }}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Bing Rank: {{ a.1.BRank|actualRank }}&lt;/font&gt;&lt;/p&gt;
  
                  &lt;/div&gt;
                  &lt;/div&gt;
                  {% endfor %}
                   &lt;div class="mamma_tab_content mtabs-1"&gt;  
                   &lt;/div&gt;
  
                   &lt;/section&gt;
  
              &lt;div id="searches"&gt;
              &lt;div class="search-wrap" id="search-wrap"&gt;
                  &lt;section class="search-content tab-content"&gt;
                  &lt;/section&gt;
              &lt;/div&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
  
                  &lt;!--&lt;div style="width: 100%; padding-bottom: 10px; clear: both; height: 100%; display: none;" id="loadmoreajaxloader"&gt;
                  &lt;center&gt;&lt;img src="http://mamma.com/static/front/images/ajax-loader.gif"&gt;&lt;/center&gt;
                  &lt;/div&gt;--&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;script language="javascript"type="text/javascript"&gt;
      var ispace_txtElements = ['result_text'];
      var ispace_brand = '';
      &lt;/script&gt;
      &lt;script type="text/javascript" src="http://mamma.com/static/front/js/ptwidget-1.0.js"&gt;&lt;/script&gt;
          &lt;!-- footer --&gt;
  
  
  &lt;footer id="footer"&gt;
                  &lt;div class="row"&gt;
                  &lt;span class="copy"&gt;&lt;p&gt; Developed By Mohit &amp; Jason  &lt;/p&gt;&lt;/span&gt;
                      &lt;ul class="footer-nav"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;  About Meta Search Engine&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
  &lt;/footer&gt;
  
  &lt;&lt;script&gt;
  $('.active').prev().removeClass( "pagenum" );
  $('.active').next().removeClass( "pagenum" );
  &lt;/script&gt;               
  
  &lt;/body&gt;
  
   &lt;/html&gt;
  </code></pre>