pop-up window focus with PDF file

I am creating a pop-up window which displays a pdf file
selected from the main WEB page and, once loaded, attempting
to get the pdf pop-up window on top.

I am using Netscape 4.x and Javascript 1.2.

Everyting opens fine except the pop-up window disappers behind
the main window.

I am unable to include some dummy <form> statement in the
pdf window (the pdf file won't display).
Is there anyway I get the pdf pop-up window on top after the
pdf document is displayed?

Here's the simple javascript (big deal huh?):
function openPDFwindow(file2open) {
      PDFWin= window.open(file2open,'ViewPDF','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=620,height=350')
}
blainerscsblAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blainerscsblAuthor Commented:
Edited text of question.
0
knightEknightCommented:
You can try this:

function openPDFwindow(file2open) {
 PDFWin = window.open(file2open,'ViewPDF','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=620,height=350');
PDFWin.focus();
}

.... but if you have HTML tags in file2open, then it is better to set the focus in there like this:

<BODY onLoad='self.focus();'>
0
blainerscsblAuthor Commented:
Doing a PDFWin.focus() doesn't work.  I even tried adding code to make sure the PDFWin window is 'created' before issuing the focus().  No luck.

Also, I am unable to insert <Body> or any other HTML tags in the PDFWin window.  Since this is displaying a pdf document  when I try to write a html tag into that window, the pdf document doesn't display (guess html and  pdf don't mix).
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

TTomCommented:
I'm being confused (or dumb).

I just tried three different methods of opening a PDF in a new window.  All of them left the new window on top (NS4.6).

<body onload="window.open('ReadMe.pdf','')">

or

<a href="javascript:window.open('ReadMe.pdf','')">Open PDF</a>

<body onload="OpenPDF()">

<script>
function OpenPDF() {
   PDFWin = window.open('ReadMe.pdf','')
}
</script>

What am I missing?

Tom

0
TTomCommented:
BTW,

The only time my PDF window did not bubble to the top was when it was already opened.

Tom
0
kmartin7Commented:
Try using a hidden frameset, 1 frame (hidden) with self.focus(), and the other with the PDF.

Open Window:

<html>
<script>
function openPDFwindow() {
  PDFWin = window.open('pdf-fset.htm', 'ViewPDF','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=350');

             }
</script>
<body>
<a href="javascript:openPDFwindow()">Open PDF Window</a>
</body>
</html>

pdf-fset.htm:
<frameset rows="0,*" border=0>
     <frame src="hidden.htm" name="hidden">
     <frame src="myPDF.pdf" name="pdf">
</frameset>

hidden.htm:
<html>
<BODY onLoad='self.focus();'>
</body>
</html>

Kurt
0
Michel PlungjanIT ExpertCommented:
Kurt: This is better - no stripe in netscape:
<frameset rows="100%,*" border=0>
   <frame src="myPDF.pdf" name="pdf">
   <frame src="hidden.htm" name="hidden">
</frameset>

and why not do this:

function openPDFwindow(file2open) {
   PDFWin=window.open('blank.html','ViewPDF','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=620,height=350')

PDFWin.document.open();
PDFWin.document.write('<frame'+'set rows="100%,*" border=0 onLoad="if (window.focus) self.focus()">');
PDFWin.document.write('<frame src="'+file2open+'" name="pdf">');
PDFWin.document.write('<frame src="hidden.htm" name="hidden">');
PDFWin.document.write('</frame'+'set>');
PDFWin.document.close();
}

0
blainerscsblAuthor Commented:
Got It!!  Thanx for help from all of you.  Here's a synopsis (plus one question to mplugjan).
TTom:  You're not confused.  I'm using a cgi.  The timer delay value I used to give the window time to load the pdf file was not enough.  I had to wait about 5 seconds for the pdf file to load into the window before giving it focus.  Once I did this, my old code worked.  But, it was klugy.

I feel the kmartin7 and mplugjan solutions are more elegant and bring the window to focus immediately.  kmartin7's code helped me understand mplugjan's elegant solution.

One question:  if i do not have the 'hidden.htm' file on my server it still works.  My question: is it imperative the hidden.htm file exists and in fact loads into the frameset?

Now to allocate the points.  I'd like to give TTom 100 for his time and making me rething my existing code.
I'd like to give 200 each to kmartin7 and mplugjan.
If this is acceptable to all, can someone tell me how to allocate the points?? (I'll start looking on the web site to figure it out).
0
TTomCommented:
Glad to hear that all is functioning the way you want it to.

To allocate points, the easiest way would be to have me post an answer to this question (worth 100 pts) and post separate questions in the same area for Kurt and Michel with appropriate point values.

I suspect the answer to your question about "hidden.htm" is that it makes limited difference.  If the web server does not find "hidden.htm", it will send back a "404 - Not found" message.  The frameset will still load.

Thanks!!

Tom
0
blainerscsblAuthor Commented:
OK Tom!  Let's do what you suggest for allocating points.  Also, thanks for clarifiy the 'hidden.htm' question.
0
TTomCommented:
Always glad to help!

Hope that Michel will verify what I said about the hidden.html file, but I'm pretty sure I'm right.  You might want to put that to him in the question you post for him.

Tom
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michel PlungjanIT ExpertCommented:
I personally use
<FRAME SRC="javascript:' '">

to have an empty frame.
I suspect that leaving the line out all together should work since we do not care about the frame at all we only need the sideeffects of a frameset.

Michel
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.