View Full Version : Remote control of Gallery

06-19-2002, 01:53 AM
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;


<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...

06-19-2002, 03:52 AM
The code wasn't written to use with iframes (I know, I wrote it... and tried to shorten the code using the slice() method before finding a bug in IE 4.0, and figured "why fix it if it ain't broke?"), but I can modify it to work with an iframe... however that would require looking at your code!

Can you supply a URL to the page? :)

06-19-2002, 03:57 AM
Originally posted by whammy

/me just a whispers® to wha...
trusting it is the type of just a ccomplishmInt® hehehe...the new n' improved db seems to have just a worked® perrrfectly...:O)))

06-19-2002, 04:03 AM
Good deal... heck you did most of the work. ;)

06-19-2002, 04:09 AM
It's a gallery but you want to link pages and not images?
can I suggest another way?
put your images in an array
instead of the iframe make a GIANT button
now the face of that button will be your image

you can put your forward and back buttons to be
one more or one less in the array

if that's no good
what immediately hit me was you're missing a "parent" in your code, it probably can't find the iframe
and try location.href

sorry, tired too
hope this is of some help if even just an idea

06-19-2002, 04:11 AM
Originally posted by whammy
Good deal... heck you did most of the work.

work??? just a rotflmao®...ohhh you meant just a greatjob® of copy/paste/edit/save/pray :O)))