navigation - Open the next html file in the directory -


i making sort of "html app" involves large number of seperate .html files. 'app' sort of 'pro tips' thing, on every page, life tip. wondering if there code opening next html file within same directory, instead of changing next tip's in each html file open it. example:

<a href="1.html">next tip</a>

in next tip's html file have put:

<a href="2.html">next tip</a>

, on:

<a href="3.html">next tip</a>

sorry if not being clear enough.

if want client-side solution might work scenario. give tag id , add script part page. parse current filename, parses number it, adds 1 , buildsup next url, replacing value on a tag

<html> <head> <script src="nav.js"></script> </head> <body> <!-- remember put id on --> <a id="next" href="n.html">next</a> </body> </html> 

and create new file called nav.js in folder , add code it:

window.onload = function() {     var a=document.getelementbyid('next'),         l=document.location.href,         s=math.max(l.lastindexof('\\'),l.lastindexof('/')),         d=l.indexof('.'),         f=l.substring(s+1,l.indexof('.')),         p=l.substring(0,s+1),         e=l.substring(s+1+f.length, l.length),         n=parseint(f,10) + 1;     if (a) {        a.href= p + n.tostring()+e;     } }; 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -