Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script for Return Next Page within HTML

Status
Not open for further replies.

slimshades26

Technical User
May 10, 2002
61
0
0
US
I've written pages in HTML and want the user to be able to press a "next page" button to see the each html page within the folder. Instead of hardcoding a link to each subsequent page in file I'd like the button or script to automatically go to the next html file in the folder. This would allow me to rearrange inbound links to the page without the pages appearing out of order, and eliminate coding error.

I can add a javascript code or any other code that will sit in a html based page. Though there are a lot of files I did not build the site as a database. Because I don't know how.

I have seen a few posts talk about return(next page) but the whole code wasn't provided (what goes in head tag and what the call on the page looks like).

so....
When user clicks on detail within a category a detail html page renders. Instead of user going back to "view all" I want user to be able to click through the detail pages one at a time if they choose.

Thanks in advance.
slimshades26

ss26
 
Am I asking the impossible? I searched and several javascript sites. I can see people have some code to do something similar to this but it's not complete enough for me to use. I'm not giving up as I think it can be done but I would very much appreciate some real help in the right direction. Thanks.

ss26
 
Hi

ss26 said:
I've written pages in HTML and want the user to be able to press a "next page" button to see the each html page within the folder.
Is it Ok for you if bots will not be able to follow the links ? That means, unless you provide an alternative list of links in a sitemap, those pages accessible through JavaScript generated links will probably not be listed in search engine results.

Anyway, basing your site's primary navigation on JavaScript is not the best idea.
ss26 said:
Though there are a lot of files I did not build the site as a database. Because I don't know how.
You could generate them with some templates. Something like some text editors mail merge functionality, but of course, more evolved.
ss26 said:
I have seen a few posts talk about return(next page)
Then please show us such post. I have no idea what such code could do.
ss26 said:
Am I asking the impossible?
No. Here is the poof that is possible :
JavaScript:
[b]var[/b] list[teal]=[[/teal]
  [green][i]'/first.htm'[/i][/green][teal],[/teal]
  [green][i]'/second.htm'[/i][/green][teal],[/teal]
  [green][i]'/third.htm'[/i][/green][teal],[/teal]
[teal]][/teal]

[b]function[/b] [COLOR=darkgoldenrod]link[/color][teal]()[/teal]
[teal]{[/teal]
  [b]var[/b] cur[teal]=[/teal]window[teal].[/teal]location[teal].[/teal]pathname
  [b]var[/b] pos[teal]=-[/teal][purple]1[/purple]
  [b]for[/b] [teal]([/teal][b]var[/b] i[teal]=[/teal][purple]0[/purple][teal],[/teal]l[teal]=[/teal]list[teal].[/teal]length[teal];[/teal]i[teal]<[/teal]l[teal];[/teal]i[teal]++)[/teal]
    [b]if[/b] [teal]([/teal]list[teal][[/teal]i[teal]]==[/teal]cur[teal])[/teal] [teal]{[/teal]
      pos[teal]=[/teal]i
      [b]break[/b]
    [teal]}[/teal]
  [b]if[/b] [teal]([/teal]pos[teal]==-[/teal][purple]1[/purple][teal])[/teal] [b]return[/b]
  [b]if[/b] [teal]([/teal]pos[teal]>[/teal][purple]0[/purple][teal])[/teal] document[teal].[/teal][COLOR=darkgoldenrod]writeln[/color][teal]([/teal][green][i]'previous'[/i][/green][teal].[/teal][COLOR=darkgoldenrod]link[/color][teal]([/teal]list[teal][[/teal]pos[teal]-[/teal][purple]1[/purple][teal]]))[/teal]
  [b]if[/b] [teal]([/teal]pos[teal]<[/teal]list[teal].[/teal]length[teal]-[/teal][purple]1[/purple][teal])[/teal] document[teal].[/teal][COLOR=darkgoldenrod]writeln[/color][teal]([/teal][green][i]'next'[/i][/green][teal].[/teal][COLOR=darkgoldenrod]link[/color][teal]([/teal]list[teal][[/teal]pos[teal]+[/teal][purple]1[/purple][teal]]))[/teal]
[teal]}[/teal]
And this is how you use it :
HTML:
[b]<html>[/b]
[b]<head>[/b]
[b]<script[/b] [maroon]src[/maroon][teal]=[/teal][green][i]"step.js"[/i][/green][b]></script>[/b]
[b]</head>[/b]
[b]<body>[/b]
[b]<script>[/b][COLOR=darkgoldenrod]link[/color][teal]()[/teal][b]</script>[/b]
[b]</body>[/b]
[b]</html>[/b]
But again, better look for another solution, not involving client-side scripting in navigation.


Feherke.
 
Only server side code can read the files in a folder and create links to the other pages.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Hi

Chris said:
Only server side code can read the files in a folder and create links to the other pages.
There is one more dirty trick : if you not have an index document and autoindexing is allowed, JavaScript could get the index generated by the web server with AJAX and parse out the links. (-:


Feherke.
 
It's a possibility. Apache generates the directory index page internally and there are some [link=http://httpd.apache.org/docs/current/mod/mod_autoindex.html].htaccess directives to control mod_autoindex[/url] (the module that handles directory browsing) and you can include header and footer files, so some javascript could be added there.


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top