jaVascript quesTion
- Started
- Last post
- 26 Responses
- Gorbie
does anyone know of some sort of javascript code that can advance and go back one page dynamically?
like say if i have page 1,2,3,4
is there a simple way to automatically retieve these pages in single increments?
thank yous,
- tomkat0
history.go(-1) no good?
- Gorbie0
thanks tomkat, but i'm not looking to use the browser's history.
i have page_01, page_02, page_03, etc.
and i wanna use a back and forward button to flip through them. it must be dynamic, though. they're not in the same frame.
- jkosoy0
i don't have the code specifically...
but you could grab the URL the user has entered and parse the string...strip out everything except the 1,2,3,4...
then you know what page you're on. from there, its real easy to increment that number.
- Gorbie0
yeah... um.........
i don't know how to do any of that. i can adapt the code and that's about it.
- Solid0
Are you saying the next/prev buttons are not in the same frame as the page_01, page_02 .. etc?
If that's the case then you already know the number of the first page that loads, so hold that in a variable and increment/decrement it each time the corresponding button is clicked ..
- Gorbie0
thanks for the response.
but you guy's are giving me waaaay too much credit.
i don't know much other than how to write html. i can't create original code.
maybe you could point me in a good direction?
thanks,
- Solid0
email me.
- heavyt0
function move(){
var cur = window.location;
cur= cur.toString();
var page = cur.substring(cur.length -1, cur.length);
var base = 0;
base++;
window.location = cur + base;
}
setTimeout(move, 1000);TR1
- rabattski0
wouldn't it be cool to have history.go(+1)
- Gorbie0
*boomp.
heavy - thanks. but i tried to work that for hours last night and couldn't get it to work. if you know of a site with explanations of a similar code, please let me know.
solid - i'll take you up on that if this takes me much longer. i hate to bug you.
- Duane0
Maybe something here would be of use.
- Gorbie0
heavyt...
what function do i use for the buttons?
- Solid0
You need to call/attach the move(); function to a button event.
Also, if I understand your needs correctly, you don't want/need the setTimeout(); function call ..
- Solid0
If you still need help just email me.
- heavyt0
yeah, the setTimeout calls the function on intervals.
If you want it to switch on a button click, you can take it out.
then make a button like this:
[a href="javascript:move();]
that will call the function.
cool?TR1
- Gorbie0
heavyt and Solid...
i just want to thank you guys. you've been awesome, and i did get it working!! I really appreciate your help.
that code you wrote, heavyt, works great.. except for one minor problem. maybe you can help... but don't bother if it's too difficult.
how can i stop the forward button? like when there are no more pages? let me know if you get a chance.
- heavyt0
inside of the function you can use a simple IF statement.
so, before the "window.location =page + base + ext;"add:
if (base > 0 && base < 4){then put a "}" after the "window.location ..."
in that case, it is checking that the page is more than 0, and less than 4. Feel free to change the numbers.
TR1
- Gorbie0
thank you so much heavt...
i'll try it out now.i owe you.
- Gorbie0
if you're still there... is there a way to modify the code to go above 10? it stops at 9 the way i have it now.
thanks bro.