title: Multiple HTML files linked to only one Javascript file
body: <p>I want to have functions in an external Javascript file to be linked to each of my html files. However, I want some functions to be linked to one html file while other functions would be linked to a different html file. Do I need to have multiple Javascript files or can I condense them into only one file? When I tried to use one Javascript file every function would run on each of my pages. Is there a way to call a specific function in html without having the whole code? Like with css using <code>#example</code> for the id <code>example</code> in html.</p>
  
  <p>I used this link in my index.html file:</p>
  
  <p><code>&lt;script type="text/javascript" src="example.js"&gt;&lt;/script&gt;</code></p>
  
  <p>While this one was in another html file:</p>
  
  <p><code>&lt;script type="text/javascript" src="example2.js"&gt;&lt;/script&gt;</code></p>
  
  <p>These links are the only Javascript included in my html files.</p>
  
  <p>I'm not sure if additional examples of Javascript or html code is needed since this seems like a general question. Although, if more code is require then please tell me what specifically and I will gladly add it. I'm also new to coding so if you could ask before downvoting I would greatly appreciate it.</p>
  
  <p>I think I found the problem. I have an RSS feed that comes through a free website but the function doesn't have anything next to it.</p>
  
  <p>The html file links to the Javascript file with this in it and because the function is blank it automatically runs or that's what i'm assuming.</p>
  
  <pre><code>(function(){
  var a=window;
  var b="";
  for(i=0;i&lt;a.rssfeed_url.length;i++) {
      b=b+"rssfeed[url]["+i+"]="+encodeURIComponent(a.rssfeed_url[i])+"&amp;"
  }
  var c="http://feed.surfing-waves.com/php/rssfeed.php"+"?"+b+"rssfeed[type]="+(a.rssfeed_type?a.rssfeed_type:"")+"&amp;rssfeed[frame_width]="+a.rssfeed_frame_width+"&amp;rssfeed[frame_height]="+a.rssfeed_frame_height+"&amp;rssfeed[scroll]="+(a.rssfeed_scroll?a.rssfeed_scroll:"")+"&amp;rssfeed[scroll_step]="+(a.rssfeed_scroll_step?a.rssfeed_scroll_step:"")+"&amp;rssfeed[scroll_bar]="+(a.rssfeed_scroll_bar?a.rssfeed_scroll_bar:"")+"&amp;rssfeed[target]="+(a.rssfeed_target?a.rssfeed_target:"")+"&amp;rssfeed[font_size]="+(a.rssfeed_font_size?a.rssfeed_font_size:"")+"&amp;rssfeed[font_face]="+(a.rssfeed_font_face?a.rssfeed_font_face:"")+"&amp;rssfeed[border]="+(a.rssfeed_border?a.rssfeed_border:"")+"&amp;rssfeed[css_url]="+(a.rssfeed_css_url?encodeURIComponent(a.rssfeed_css_url):"")+"&amp;rssfeed[title]="+(a.rssfeed_title?a.rssfeed_title:"")+"&amp;rssfeed[title_name]="+(a.rssfeed_title_name?a.rssfeed_title_name:"")+"&amp;rssfeed[title_bgcolor]="+(a.rssfeed_title_bgcolor?encodeURIComponent(a.rssfeed_title_bgcolor):"")+"&amp;rssfeed[title_color]="+(a.rssfeed_title_color?encodeURIComponent(a.rssfeed_title_color):"")+"&amp;rssfeed[title_bgimage]="+(a.rssfeed_title_bgimage?encodeURIComponent(a.rssfeed_title_bgimage):"")+"&amp;rssfeed[footer]="+(a.rssfeed_footer?a.rssfeed_footer:"")+"&amp;rssfeed[footer_name]="+(a.rssfeed_footer_name?a.rssfeed_footer_name:"")+"&amp;rssfeed[footer_bgcolor]="+(a.rssfeed_footer_bgcolor?encodeURIComponent(a.rssfeed_footer_bgcolor):"")+"&amp;rssfeed[footer_color]="+(a.rssfeed_footer_color?encodeURIComponent(a.rssfeed_footer_color):"")+"&amp;rssfeed[footer_bgimage]="+(a.rssfeed_footer_bgimage?encodeURIComponent(a.rssfeed_footer_bgimage):"")+"&amp;rssfeed[item_bgcolor]="+(a.rssfeed_item_bgcolor?encodeURIComponent(a.rssfeed_item_bgcolor):"")+"&amp;rssfeed[item_bgimage]="+(a.rssfeed_item_bgimage?encodeURIComponent(a.rssfeed_item_bgimage):"")+"&amp;rssfeed[item_title_length]="+(a.rssfeed_item_title_length?a.rssfeed_item_title_length:"")+"&amp;rssfeed[item_title_color]="+(a.rssfeed_item_title_color?encodeURIComponent(a.rssfeed_item_title_color):"")+"&amp;rssfeed[item_border_bottom]="+(a.rssfeed_item_border_bottom?a.rssfeed_item_border_bottom:"")+"&amp;rssfeed[item_source_icon]="+(a.rssfeed_item_source_icon?a.rssfeed_item_source_icon:"")+"&amp;rssfeed[item_date]="+(a.rssfeed_item_date?a.rssfeed_item_date:"")+"&amp;rssfeed[item_description]="+(a.rssfeed_item_description?a.rssfeed_item_description:"")+"&amp;rssfeed[item_description_length]="+(a.rssfeed_item_description_length?a.rssfeed_item_description_length:"")+"&amp;rssfeed[item_description_color]="+(a.rssfeed_item_description_color?encodeURIComponent(a.rssfeed_item_description_color):"")+"&amp;rssfeed[item_description_link_color]="+(a.rssfeed_item_description_link_color?encodeURIComponent(a.rssfeed_item_description_link_color):"")+"&amp;rssfeed[item_description_tag]="+(a.rssfeed_item_description_tag?a.rssfeed_item_description_tag:"")+"&amp;rssfeed[no_items]="+(a.rssfeed_no_items?a.rssfeed_no_items:"")+"&amp;rssfeed[cache]="+(a.rssfeed_cache?a.rssfeed_cache:"");
  if(a.rssfeed_border!="off"&amp;&amp;!a.rssfeed_css_url){}
  document.write('&lt;iframe name="rssfeed_frame" width="'+a.rssfeed_frame_width+'" height="'+a.rssfeed_frame_height+'" frameborder="0" src="'+c+'" marginwidth="0" marginheight="0" vspace="0" hspace="0" scrolling="no" ALLOWTRANSPARENCY="true"&gt;&lt;/iframe&gt;')
  })()
  </code></pre>
  
  <p>The only problem now is that I don't know how to call the function. Another function I have is called because I have <code>onClick="example()"</code> which is fine for that but the RSS feed needs to load automatically. I don't want to have to click a button to get the feed to appear.</p>