Or, at least, I think it is.

vtm-book.zxq.net

The first page with the menu works just fine, but when you go to any of the other pages it won't let you highlight the text to copy and paste - in certain circumstances.

It works fine on my home computer which is running Windows XP. I've been able to work with it in all browsers.

On Windows Vista and Windows 7 there are issues. The only real difference is the previous/next page menu and the switch div script which is written in Javascript. This is the only thing I can think that's interfering. I've only tested Internet Explorer and Chrome in Vista (don't know about Chrome in 7) but it inhibits in both browsers.

Does anyone have any ideas as to why? Might there be any work arounds? On 14.html which is the Index (as in book, not the main web page) the switch div is gone but it's still not working. However, I tested just the switch div script on another web-site without the previous/next page menu and that also doesn't work.

This is the javascript for the previous/next menu:

/*Put in the html <head> tags.*/
<script> 
function nextPg(step) { 
  var str = window.location.href;
  if(pNum = str.match(/(\d+)\.htm/i)){
    pNum = pNum[1] * 1 + step+'';
    if(pNum>0){
      pNum = "".substr(0, 4-pNum.length)+pNum;
      window.location = str.replace(/\d+\.htm/i, pNum+'.htm'); 
    }
  }
} 
</script>


/*Put in the body.*/
<a href="javascript:nextPg(-1)">&laquo; Previous Page</a></div><div style="width: 333px; float: left; text-align:center;"><a href="index.html">Table of Contents</a></div><div style="float:right;"><a href="javascript:nextPg(+1)">Next Page &raquo;</a>

This is the switch div code:

/*Put in the html <head> tags.*/
<script type="text/javascript">
/*
Script made by Martial Boissonneault © 2001-2003 http://getElementById.com/
This script may be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*/
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("cont").getElementsByTagName("DIV");
if(el.style.display == "none"){
for (var i=0; i<ar.length; i++){
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
function ChangeClass(menu, newClass) {
if (document.getElementById) {
document.getElementById(menu).className = newClass;
}
}
document.onselectstart = new Function("return false");
</script>


/*Put in the body.*/
<a href="javascript:SwitchMenu('sub1')">/*IMAGE HERE*/</a>
<div id="sub1" style="display:none;">/*HIDDEN DIV CONTENT*/</div>

This part

document.onselectstart = new Function("return false");

will prevent you from highlighting text.

Your SwitchMenu() function is so out dated. You can now use 'document.getElementById()' on any browser without checking for the existence of the function nowadays. Also, accessing 'style.display' directly that way may not be working correctly. You already have the 'ChangeClass()' function, use it to change the display and use CSS (class name) instead. Or you don't need the function and access the class name directly. I am going to show you by modifying your code (try to keep it as it is).

<style type="text/css">
div.showing {
  /* you may not need to give a value to display */
}
div.hiding {
  display: none;
}
</style>

function SwitchMenu(objId) {
  var el = document.getElementById(objId);
  if (el) { // ensure that the element exists here
    var ar = document.getElementById("cont").getElementsByTagName("DIV");
    if (el.className.match(/hiding/) {
      for (var i=0; i<ar.length; i++) {
        ar[i].className += " hiding"
      }
      el.className = el.className.replace(/hiding/, "showing");
    }
    else {
      el.className = el.className.replace(/showing/, "hiding");
    }
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.