View Full Version : Previous/Next Button Target IFRAME

07-09-2010, 01:38 AM
I am trying to make a site that will load a webpage into an iframe using previous/next buttons to cycle through and load into the iframe sequential html pages. I have found code, posted here, that gets pretty close to this effect, but it only targets framesets. I hate frames and really don't like using iframes. I am looking for a way to either achieve this effect by editing the code I have or achieving the effect using a div and some javascript. Here is the code I am using now (I was wondering if it would be possible to modify it to target an iframe).

<FRAME SRC="1.html" NAME="main" marginheight=0 marginwidth=0>
<FRAME SRC="n.html" NAME="navi" marginheight=0 marginwidth=0>

n.html page:

var start = 1, end = 3, nr = 1, index = "index.html";

function fChange( num ) {
fname = top.frames[0].location.href;
// alert('fname='+fname);
ii=0; jj=0;
for(i=0;i<fname.length;i++) {
if(fname.charAt(i) == '/') ii=i;
if(fname.charAt(i) == '.') jj=i;
nr = parseInt( fname.substring(ii+1,jj) )+ parseInt(num);
if ((nr>=start) & (nr<=end)) {
top.frames[0].location.href = ""+ nr +".html";
else top.frames[0].location.href = index;
// --></script>
<body><div align="center"><center>
<a href="#" onClick="fChange('-1')" >previous</a> &nbsp; = &nbsp;
<a href="#" onClick="fChange('+1')" > next </a>