By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,007 Members | 1,025 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,007 IT Pros & Developers. It's quick & easy.

Window.focus() (or window.print()) problem with XP/SP2 ?

P: 5
Didn't get answer with google and in my regular forum. Came across this site and posting here. Your help will be highly appreciated !

Our application have frames - MainNav, TaskNave and Content. When print button is clicked, it prints only the Content (obviously top.Content.focus() is in the code before window.print()). We were using windows 2000 & IE6 for years. Recently, our installation updated users machines with XP SP2. Now when print button is clicked, all three frames get printed in 3 pages. Same application, if used from XP SP2, 3 pages gets printed where as when used from W2K, only 1 page is printed. I looked all over place, didn't find any information on focus not working correctly with XP SP2. I tried so many things but no luck. Please help!
MainNav.jsp
--
<TD><A tabIndex=-1 href=#><IMG SRC="<%= imagePath %>/images/button_print.gif" ALT="Print" onClick="if (window.print) { top.Content.focus(); window.print(); }" border="0"></A></TD>
--
frameset.jsp
--
<FRAMESET ROWS="134,*" border="0" onload="resetTimer();" onunload="exitAlertWindow();">
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="MainNav" SRC="<%= commandPath %>/CSES/Main/displayMainNav" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no" FRAMEBORDER="0" NORESIZE TABINDEX="-1">
<FRAMESET COLS="180,588,*" border="0">
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="TaskNav" SRC="<%= commandPath %>/CSES/Main/displayTaskNav" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="auto" class=TA FRAMEBORDER="0" NORESIZE TABINDEX="-1">
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="Content" SRC="<%= commandPath %>/CSES/Main/displayWelcome<%= strMiscMessage %>" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="auto" FRAMEBORDER="0" NORESIZE>
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="Blank" SRC="<%= imagePath %>/common/blankPage.html" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no" FRAMEBORDER="0" NORESIZE>
</FRAMESET>

Now what I found:

On onclick for print, when I change top.Content.focus(); to top.MainNav.focus() it does print only MainNav; if I change to top.TaskNav.focus() it prints only TaskNav, but when I change to top.Blank.focus(), this prints multiple pages just like top.Content.focus().

So what I know is focus() does work on other 2 frames, but not on Content and Blank with XP SP2. With W2K IE6, everything works fine.

Tried changing the name of Content to something else, still didn't work. The site is intranet.

Any one has any idea what might be the reason that this code broke in XP SP2. Thanks.
Mar 5 '07 #1
Share this Question
Share on Google+
8 Replies


Expert 100+
P: 392
What is the status of the "Blank" frame when it is being printed? If its visiblity or other CSS attributes are set to make it not visible then this could be why it is printing the entire frameset instead of just that frame. i.e. IE might be trying to print that page, but when it goes there and sees there is nothing to print it assumes you must want to print the frameset content since there would be no point in trying to print a blank page.
Mar 5 '07 #2

P: 5
Ok, blank is visible. The problem happens in both, Content and Blank. For both entire frameset is printed.
I tried few more things, and might be close - but still not there. Need your help.

1) I started playing with the frame order on frameset. Now when I put Blank at the left most, then TaskNav and then Content - and try focus on each of them on by one for printing - Now Blank printed correctly, TaskNav printed correctly but for Content every frames printed.

2) Changed order again, Now Blank, Content and TaskNav - This time all 3 printed correctly.

--> The conclusion I drawn is what ever frame is put after TaskNav, it cannot focus and print just that frame.

So something to do with TaskNav.jsp.

--> TaskNav.jsp is a long jsp with all the left menu items with their links. I made it a blank jsp with hardly anything in it. Now everything works fine, even the frames after the TaskNav.

Now I started putting the code in TaskNav.jsp one section of menu at a time, and test the print. I saw that after few sections, at one point it stops working. No matter what code I put. Is this has anything to do with the length of jsp??

Again the same code works fine with SP1 but XP/SP2 seems to have problem. Can you suggest anything I can try?

Thanks a lot.
Mar 5 '07 #3

sumittyagi
Expert 100+
P: 202
Didn't get answer with google and in my regular forum. Came across this site and posting here. Your help will be highly appreciated !

Our application have frames - MainNav, TaskNave and Content. When print button is clicked, it prints only the Content (obviously top.Content.focus() is in the code before window.print()). We were using windows 2000 & IE6 for years. Recently, our installation updated users machines with XP SP2. Now when print button is clicked, all three frames get printed in 3 pages. Same application, if used from XP SP2, 3 pages gets printed where as when used from W2K, only 1 page is printed. I looked all over place, didn't find any information on focus not working correctly with XP SP2. I tried so many things but no luck. Please help!
MainNav.jsp
--
<TD><A tabIndex=-1 href=#><IMG SRC="<%= imagePath %>/images/button_print.gif" ALT="Print" onClick="if (window.print) { top.Content.focus(); window.print(); }" border="0"></A></TD>
--
frameset.jsp
--
<FRAMESET ROWS="134,*" border="0" onload="resetTimer();" onunload="exitAlertWindow();">
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="MainNav" SRC="<%= commandPath %>/CSES/Main/displayMainNav" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no" FRAMEBORDER="0" NORESIZE TABINDEX="-1">
<FRAMESET COLS="180,588,*" border="0">
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="TaskNav" SRC="<%= commandPath %>/CSES/Main/displayTaskNav" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="auto" class=TA FRAMEBORDER="0" NORESIZE TABINDEX="-1">
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="Content" SRC="<%= commandPath %>/CSES/Main/displayWelcome<%= strMiscMessage %>" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="auto" FRAMEBORDER="0" NORESIZE>
<FRAME ONREADYSTATECHANGE="hidepane();" NAME="Blank" SRC="<%= imagePath %>/common/blankPage.html" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no" FRAMEBORDER="0" NORESIZE>
</FRAMESET>

Now what I found:

On onclick for print, when I change top.Content.focus(); to top.MainNav.focus() it does print only MainNav; if I change to top.TaskNav.focus() it prints only TaskNav, but when I change to top.Blank.focus(), this prints multiple pages just like top.Content.focus().

So what I know is focus() does work on other 2 frames, but not on Content and Blank with XP SP2. With W2K IE6, everything works fine.

Tried changing the name of Content to something else, still didn't work. The site is intranet.

Any one has any idea what might be the reason that this code broke in XP SP2. Thanks.

Ok then try this:
window.frames["content"].print();
Mar 6 '07 #4

sumittyagi
Expert 100+
P: 202
Ok then try this:
window.frames["content"].print();
sorry I rectify myself:
top.frames["content"].print();
Mar 6 '07 #5

P: 5
Sorry, didn't work ! Any other idea ?
sorry I rectify myself:
top.frames["content"].print();
Mar 6 '07 #6

P: 5
Any one ? Seems like its the lenght of jps (TaskNav.jsp). If I take out some code out of TaskNav.jsp, the print of Content works. Kind of wierd. I don't see any errors on the code of TaskNav. Just menus coded in jsp tags.
Any one know any relation of length of jsp (means, long code in jsp) with the focus/print or frame problem ?
Mar 7 '07 #7

P: 1
Hi,

I also have got the same problem with our intranet-application after we installed XP/SP2 :-(

I try to print a frame with a PDF. With SP1 this worked fine (set focus on the corresponding frame and then print () ). with SP2 I only get an empty page with the printed link to the file on the server. :-(


Does anybody find a solution for this problem?
Mar 12 '07 #8

P: 5
Good to know that its just not me...
One more thing I like to add, forget my print button. If I right click the frame I want to print (Content) and do print, it still prints all 3 frames....
Any one ?
Hi,

I also have got the same problem with our intranet-application after we installed XP/SP2 :-(

I try to print a frame with a PDF. With SP1 this worked fine (set focus on the corresponding frame and then print () ). with SP2 I only get an empty page with the printed link to the file on the server. :-(


Does anybody find a solution for this problem?
Mar 12 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.