Casper van Zoest Casper van Zoest - 2 years ago 80
AngularJS Question

HTML - Running Javascript from another HTML page?

I am working on my website, but I have a big issue with the menu. Some HTML files include more pages, so I would like all pages directly accessible from the menu.

Please have a look at the following website:

When you want to enter an INFO page, you can select it from the menu, but it will be only visible if you are already on the info page. This means that you have to select the page twice.

Please let me know how I can prevent this.


function show(shown, hidden, hidden2) {
window.location = 'info/index.html';
return false;

html menu

<div id="menu">
<ul id="nav">
<a href="index.html">
<div id="menuitem">Home</div>
<li><a href="#">
<div id="menuitem">Info</div>
<li><a href="info/index.html" onclick="return show('Page1','Page2','Page3');">Doelstelling</a></li>
<li><a href="info/index.html" onclick="return show('Page2','Page1','Page3');">Bestuur</a></li>
<li><a href="info/index.html" onclick="return show('Page3','Page1','Page2');">Lid worden</a></li>
<a href="activiteiten/index.html">
<div id="menuitem">Activiteiten</div>
<a href="fotos/index.html">
<div id="menuitem">Foto's</div>
<a href="links/index.html">
<div id="menuitem">Links</div>
<a href="tehuur/index.html">
<div id="menuitem">Te huur</div>

html on INFO page

<div id="Page1" style="display:none">



<div id="Page2" style="display:none">



<div id="Page3" style="display:none">



Please have a look at the website link to see what I mean,
try to open an INFO-page twice.

Answer Source

I would also suggest to solve this problem with URL parameter:

And then you can check the url parameter when the page is loading. Depending on the parameter value you can show and hide the content. Code for reading the url parameter could be something like:

function getParam(variable){  
  var query =;   
  var parameter = query.split("&");  
  for (var i=0; i< parameter.length; i++) {    
        var pair = parameter[i].split("=");   
        if(pair[0] == variable){
          return pair[1];
var external = getParam('external');
var page = getParam('page');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download