I am trying to create this page where I have a single Iframe and I want to add a button to show a next page in the iframe, and a button to show the previous page in the iframe.
I have a total of 4 pages to show in the iframe named 1.html 2.html 3.html 4.html and I would like the buttons to work going from 1 to 4 and then go back to 1 and so on.
the sketch is something like this:
_________
| IFRAME |
| |
___________
<<previous Next >>
This is a simple script that I made to change the content of the iframe
This is the iframe / Button / function.
<iframe id="screen" width="609" scrolling="no" height="410" frameborder="0" align="middle" name="canal" src="1.html"></iframe>
<input type="button" onclick="content2()" class="butonactual" value="See 2">
<script> function content2() { document.getElementById('screen').src = "2.html"; } </script>
Thanks
If I understand the question, you have 4 urls and are using a single iframe. If such is the case, use an array to store the urls and a counter (which is an index into the array). When next is pressed, increment the counter and switch the iframe url. Previous decrements the counter and does the same.
Not too difficult, just change the src tag of the iframe. Let's assume the below is your html:
Then you could do it as explained below:
jQuery
Alternatively, just add the markup to your anchor tags to call these functions:
UPDATE
If you wanted to use buttons instead of anchor tags, leave the jQuery the same, and just change your anchor tags for buttons, as such
UPDATE2: Tested code using javascript only, no jQuery
Using Jquery
■Update