Got given most of this script for a gallery I'm setting up, you click a button on a page and the code works out the current doc name and adds a number to the end... i.e. was page1.html, when you click next it takes you to page2.html. You have to put in the number of pages of course, so it knows if you get to page7.html it should stop....
Anyway, my gallery displays a page1.html in a <iframe>, and the controls are on the parent doc.... I've tried codeing every which way but i'm a tool and missing it completely....
here it is...
var txt = document.viewer.location.toString()
parts = txt.split("/");
path = parts[(parts.length-1)];
path = path.split(".");
doc = path[0];
docext = path[1];
docname = doc.replace(/\d/g,'');
docnumber = Number(doc.replace(/\D/g,''));
function goback(){
if (docnumber!=0){ // replace 0 with your first page!
document.viewer.location = "gallery/"+docname+(docnumber-1)+"."+docext;
}
}
function goforward(){
if (docnumber!=3){ // replace 3 with your last page!
document.viewer.location = "gallery/"+docname+(docnumber+1)+"."+docext;
}
}
</head><body>
<iframe name="viewer" src="gallery/page0.html"><iframe>
<input type="button" onclick="goforward()" value="next">
<input type="button" onclick="goback()" value="back">
//I'm pretty sure the problem resides in the docnumber check,
//But it is a little over my head......
//Thanks for the help...
Anyway, my gallery displays a page1.html in a <iframe>, and the controls are on the parent doc.... I've tried codeing every which way but i'm a tool and missing it completely....
here it is...
var txt = document.viewer.location.toString()
parts = txt.split("/");
path = parts[(parts.length-1)];
path = path.split(".");
doc = path[0];
docext = path[1];
docname = doc.replace(/\d/g,'');
docnumber = Number(doc.replace(/\D/g,''));
function goback(){
if (docnumber!=0){ // replace 0 with your first page!
document.viewer.location = "gallery/"+docname+(docnumber-1)+"."+docext;
}
}
function goforward(){
if (docnumber!=3){ // replace 3 with your last page!
document.viewer.location = "gallery/"+docname+(docnumber+1)+"."+docext;
}
}
</head><body>
<iframe name="viewer" src="gallery/page0.html"><iframe>
<input type="button" onclick="goforward()" value="next">
<input type="button" onclick="goback()" value="back">
//I'm pretty sure the problem resides in the docnumber check,
//But it is a little over my head......
//Thanks for the help...
Comment