title: Script to dynamically change the source of an iframe tag
body: <p>I want a code that will dynamically change the source of an iframe tag when a hyperlink is clicked for example I have one master page that should load content from other web pages using the iframe tag when a hyperlink is clicked but I don't know how to do it. Here is my code</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;
      &lt;/title&gt;
  
      &lt;style type="text/css"&gt;
        #content {
          margin-right:30%;
          margin-bottom: 10px;
          padding: 10px;
          border: 1px solid #000;
          margin-left: 17%;
          background-repeat: no-repeat;
          width: 686;
          height: 640;
        }
      &lt;/style&gt;
  
      &lt;script type="text/javascript"&gt;
  
        function hyperlinkChanger(hyperLink) 
        {
  
          switch (hyperLink)
          {
  
            case "home":
              var url="home.html";
              return url;
              break;
  
            case "about_Us":
              var url="about_us.html";
              return url;
  
              break;
  
            case "contact_Us:
              var url="contact_us.html";
              return url;
  
              break;
          }
        }
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;a href="home.html" name="home" onClick="hyperlinkChanger('home')"&gt;Home&lt;/a&gt;
      &lt;br /&gt;
      &lt;a href="about_us.html" name="about_Us" onClick="hyperlinkChanger('about_Us')"&gt;About Us&lt;/a&gt;
      &lt;br /&gt;
      &lt;a href="contact_us.html" name="contact_Us" onClick="hyperlinkChanger('contact_Us')"&gt;Contact us&lt;/a&gt;
      &lt;br /&gt;
  
      &lt;div name="content"&gt;
        &lt;!--please help me write a method to call the output of the funcion hyperlinkChanger--&gt;
        &lt;iframe src="hyprlink function" width="600" height="300"&gt;
        &lt;/iframe&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>