Hello,
I have a web page that shows the content of a book. It shows it up in this order:
- Title of the book
- a line (row) showing the chapters (Chapter: 1 2 3 4 5 6 etc.)
- the text of the book.
Clicking a chapter (in #2 above), the text jumps to the related chapter (by calling its ID class).
So far so good. Yet, using this approach, scrolling the text, users don’t see anymore the line showing the chapters. They have to scroll back to the top of the page.
So I thought of using a frameset. Accordingly I broke the original file into two files (myBook1 and myBook2), where myBook1 contains only
- Title
- the line (row) showing the chapters (Chapter: 1 2 3 4 5 6 etc.)
Now, executing the snippet below I get, in frame #2, the text positioned at chapter 4, and users can access the Chapter line since it is always visible, being part of frame #1.
//two horiz. frames
//title and "Chapter line"
//the text, positioned at chapter 4
The problem I cannot overcome is how to code the “Chapter line”. In fact the following snippet brings up the text at the selected chapter,
but --of course-- it puts it into frame #1; while I need it in frame #2.
//this is the code for the “Chapter line”: clicking a number, it should bring up the text positioned at the corresponding chapter.
Chapter: 1 2 etc.
Hence my question, is there a way to code (for instance)
4
so that it goes into frame #2?
Thank you.
Look into the target attribute of the a tag.
Thom,
thank you for pointing me in the right direction.
Quoting from w3schools
[quote]The target attribute can have one of the following values:
_blank - Opens the linked document in a new window or tab
_self - Opens the linked document in the same window/tab as it was clicked (this is default)
_parent - Opens the linked document in the parent frame
_top - Opens the linked document in the full body of the window
framename - Opens the linked document in a named frame[/quote]
Therefore I set a name to each of the two frames.
1 //etc
Unfortunately, using _self or _blank or only the framename does not make any difference: the text always opens in a new window.
Obviously I’m missing something.
Again, thank you.
I’m not sure what you’re missing from the sample code you’ve posted. Setting the name of a frame, then using target=“name” is the right way to do it. A frameset usually takes up the whole viewport, so a link on the outside of a frameset is not something I’d expect.
Thom,
things now work OK, only that instead of two files I need three files: myBook0.html, myBook1.html, myBook2.html
myBook0.html sets the frameset:
myBook1.html contains title and chapter-line (1 //etc
myBook2.html contains the actual text
To load a book I just call myBook0.html (),
and I get the two frames populated, then clicking a chapter in the top frame (“mTop”), the bottom frame jumps to the right chapter.
Again, thank you.