/    Sign up×
Community /Pin to ProfileBookmark

Printing Only the main frame

I am working with a client who wanted his site developed with frames.. ugh.. I know. Well, now that the dirty work is done. I am having problems getting only the main frame (the one on the right) to print. I have three html pages that make up index.html.

index.htm
home.htm (main – right frame)
navbar.htm (content – left frame)

I used the following scripts: in my home.htm (main frame) and not on the navbar.htm and uploaded to the server.

Not only do I get a pop-up dialog box for printing (bad), but it still is only printing the navbar.

Any suggestions .. or ??

Site reference [url]http://www.sensitrac.com/test[/url]

<script language=”JavaScript”>
<!– hide this script from non-javascript-enabled browsers
/* Functions that open and control pop-up window */
function openWin(URL) {
aWindow = window.open(URL, ‘newWindow’,’width=620,height=550,directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes’);
}
// stop hiding –>
</script>

<script language=”JavaScript” type=”text/JavaScript”>
parent.main.focus ( );
parent.main.print ( );
</script>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SamFeb 09.2004 — first off, I'd imagine you don't want to have this print onload, just cuz that would piss people off. you should have a button that says print, or something.

Second, you _can't_ print without the dialog, it creates too many security issues.

Third, take the scripts out of your framset page, they shouldn't be there.

Once these changes have been made, all you will need to do is put a function on the right pages that has the line window.print()

So long as the script is in the correct frame, you shouldn't have any problems.
Copy linkTweet thisAlerts:
@thebeginnerauthorFeb 09.2004 — sami -

thank for responding.. however, I am a very much a novice when it comes to javascript. I totally understand the not wanting the pop-up print box thing.. I just wasn't sure how I got it to come up in the first place.

So what you are saying is remove the script from the head tag of index.htm..put it where..? ? what about the 2 pages that make up index.htm.. (home.htm and navbar.htm) do they get the script too???

should I just use the same script below: in the pages I want to be able to print the main frame and does it go in the body tag...? or head?

<script language="JavaScript" type="text/JavaScript">

parent.main.focus ( );

parent.main.print ( );

</script>

thanks again,

very very beginner : - )
×

Success!

Help @thebeginner 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...