I want to change the css and the mainpage at the same time
The index.html and sub.html look almost the same, but the sub.html doesn't have the "a" - Tags for links and just a one back and forward btn.
I know if I change the html the new header should contain the right css in the "head"-Tag.
Maybe I need a global var but I don't know how to use it in javascript.
This example has only nr01 to nr03 ... the final document will have up to 20 at start and later more... and I don't want to change all documents in the future because the number of items changes. That's why I'm choosing this way.
<!DOCTYPE html><html>
<head>
<meta charset="utf-8"/>
<link type="text/css" rel="stylesheet" href="CSS/style.css" />
<link type="text/css" rel="stylesheet" href="CSS/nr00.css" />
<script type="text/javascript" src="JS/loadcss.js"></script>
</head>
<body>
<div class="content">
<div class="item nr01"><a href="javascript:othercss('css/nr01.css')" onclick="href='sub.html';">a</a></div>
<div class="item nr02"><a href="sub.html" onclick="othercss('css/nr02.css');return false;">b</a></div>
<div class="item nr03"><a href="sub.html" onclick="javascript:othercss('css/nr03.css')">c</a></div>
</div>
</body>
The JS file
//JavaScript Document
function othercss(dat)
{setTimeout(function(){document.getElementsByTagName('link')[1].href=dat}, 200);alert ('here load the html?');}
The first link showed the sub.html but didn't load the javascript.
The second loaded the javascript and changed the css, but didn't load the sub.html
The third link loaded the javascript and loaded sub.html but didn't change the css.
Could I load the sub.html first and then have a function change the css file?