Simple document changer in a frame.

A

Alan Clark

Dear All

I need to do something very simple with Javascript and have been looking
all over the web for two days for a suitable script. I'm the kind of person
who learns by seeing how it's done. I am a real beginner in programming.

I am making a baking recipe site. For each section, say cookies, I will
have around 100 recipes, which will be named sequentially, 001.html -
100.html for example.

I want to be able to have a simple navigation frame with buttons for first,
previous, next and last with the recipes appearing in the content frame.
The recipes are simple html pages with no images at this stage.

Can anyone help?

Many thanks in advance.


Alan Clark
Mature Student
University of Hertfordshire.
UK.
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
Dear All

I need to do something very simple with Javascript and have been looking
all over the web for two days for a suitable script. I'm the kind of person
who learns by seeing how it's done. I am a real beginner in programming.

I am making a baking recipe site. For each section, say cookies, I will
have around 100 recipes, which will be named sequentially, 001.html -
100.html for example.

I want to be able to have a simple navigation frame with buttons for first,
previous, next and last with the recipes appearing in the content frame.
The recipes are simple html pages with no images at this stage.

You might do better to start at Number 100. Ignoring that, and starting
on, say, 023.html

Consider H = String(+H.substring(0,3)+1001).substring(1, 4)+".html"
with each H replaced by location.href and placed on each page as the
action of a button; and similar with 999 instead of 1001. On the first
and last pages, omit the inapplicable.

Beginning & end just need direct assignment to location.href .

Similar can presumably be used with frames.
 
A

Alan Clark

Dr John Stockton said:
JRS: In article <[email protected]>, seen in


You might do better to start at Number 100. Ignoring that, and starting
on, say, 023.html

Consider H = String(+H.substring(0,3)+1001).substring(1, 4)+".html"
with each H replaced by location.href and placed on each page as the
action of a button; and similar with 999 instead of 1001. On the first
and last pages, omit the inapplicable.

Beginning & end just need direct assignment to location.href .

Similar can presumably be used with frames.


Thanks for the help John. It's a little hard for me to grasp
immmediately. I've managed to alter some array code I downloaded and
I've made it do what I want, but there is a great deal of redundancy.
I have over 100 pages as I said and making over 100 array elements
doesn't seem like good coding. As I said,my experience is very limited
- mostly confined to programming DBase, with some instruction last
year in VB on my course - which is 'Software Systems for the Arts and
Media' at Hatfield.

Here is what I've been altering...

<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
<!-- Begin Previous Buttons script
// place in HEAD section
// script created by : THeMaRTy
// website: http://marty.excudo.net
// saved from url=(0050)http://marty.excudo.net/scripts/navigate/menu.html
var count=1;
// the array with the links
// you can add as many links as you like, as long as you keep the
numbers succeeding
var link_array = new Array();
link_array[1] = '001.html';
link_array[2] = '002.html';
link_array[3] = '003.html';
link_array[4] = '004.html';
link_array[5] = '005.html';
link_array[6] = '006.html';
// skip fwd
function next()
{
if ((count + 1) >= link_array.length)
{
alert('That was the last page');
}
else
{
count = count + 1;
parent.frames['main'].document.location.href = link_array[count];
}
}
// skip back
function previous()
{
if ((count - 1) <= 0)
{
alert('This is the first page');
}
else
{
count = count - 1;
parent.frames['main'].document.location.href = link_array[count];
}
}
// end -->
</SCRIPT>


Thanks for your help.

Alan Clark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top