Photogallery.. Trying to have a single html page.. it has links to images.. buttons on the page 'aim to' modify the path to the images by finding the name currently in the path and replacing it with the name of the gallery corresponding to the button the user clicked on..
example:
Expand|Select|Wrap|Line Numbers
- GALLERY2go : function(e) {
- if(GalleryID!="landscapes")
- {
- var find = ''+ findGalleryID()+'';
- var repl = "landscapes";
- var page = document.body.innerHTML;
- while (page.indexOf(find) >= 0) {
- var i = page.indexOf(find);
- var j = find.length;
- page = page.substr(0,i) + repl + page.substr(i+j);
- document.body.innerHTML = page;
- var GalleryID = "landscapes";
- }
- }
- },
Expand|Select|Wrap|Line Numbers
- var GalleryID = "portfolio";
- function findGalleryID() {
- return GalleryID
- }
The code, given its frailties or otherwise ridiculousness, actually does change all of the image links (and absolutely everything else called "portfolio") in the html page - hence "portfolio" becomes "landscapes".. the path to the images changes and they all update.. As a JavaScript beginner I was pretty chuffed to see it worked. But you can't click on another gallery button because it's stuck in a loop of some sort. In fact, after you click the button you can't click on anything else and all of the rest of the JavaScript functionality is buggered. Perhaps I've introduced some kind of loop it never exits. If you click on portfolio when you're in portfolio you crash the browser! Anyway I'm well aware that 'my cobbled together solution' is not how it would be done by someone with any experience in writing code. They'd probably use something else with a different name that takes another lifetime to learn. I don't think I can use getElement by and refer to the class/id name and parse the filename [using lots of words I don't at all understand] because of the implications on the other parts of the script. I've tried using a div wrapper and code to launch a child html doc and that come in without disposing of the existing content or talking to the stylesheet. I'm bloody lost and don't even know where to start looking next.