/    Sign up×
Community /Pin to ProfileBookmark

Print last frame?

Situation: using authoring tool (RoboHelp) to build online information (help) system. Information displays in multi-framed browser window. Frames include nav bars across top, nav pane (TOC, Index, Glossary) at left, content pane right. Content pane occasionally is split into two additional frames.
Currently using this Javascript function, which prints the content pane, including both frames if there are two:

window.parent.frames[1].frames[1].focus();window.print();

Challenge: Modify Javascript to print only the last frame in the content pane, no matter how many frames in browser. Complication: don’t know and can’t get frame names.

Possible solution: Javascript bit to:
1) count frames (using something like window.length?)
2) print the last frame

Problem: I’m a writer, not a developer. Can understand, modify Javascript–but create from scratch?–no way. I need help.

Thanks in advance.

[code=php]window.parent.frames[1].frames[1].focus();window.print();[/code]

[FONT=courier new]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriJan 07.2004 — not completly sure how to do that but it would be something along lines of

window.parent.frames[3].frames[3].focus();window.print();

onerror

window.parent.frames[2].frames[2].focus();window.print();

that is presuming the content pane is the third frame therefore if splits in two making it third and forth

tries printing fourth frame if returns error prints third
Copy linkTweet thisAlerts:
@DrWordauthorJan 08.2004 — Dug out a solution.

I think it's elegant.

[code=php]
function printContent()
{
if (top.frames[1].frames[1].frames[1] != null)
{
top.frames[1].frames[1].frames[1].focus();
window.print();
}
else
{
top.frames[1].frames[1].focus();
window.print();
}}[/code]
×

Success!

Help @DrWord spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...