Solved

pop up windows

Posted on 1998-05-08
8
511 Views
Last Modified: 2013-11-28
I have tried the following two codes to get a pop up window that will display a definition. I have two examples with a question for each below.  Thanks for your help!
-----------------------------------
My problem in example #1 below is that the alert box (pop up window) plays a sound (alert sound) on the Mac Computers who view it.  

QUESTION:
What can I add to the code so users don't hear the sound
and
How can I define the size and location of the alert window (or is that not possible)
------------------------------------
Example#1

<CENTER><FORM><INPUT TYPE="button" Value=" Software  "
           onClick="alert('This is my definition of the work "software"')")>
      </TD>
-------------------------------
My problem in example #2 below is that the pop up window does not stay on the top (forefront).  If someone double clicks the button then the pop up window can't be seen as it is behind the main window.  Also if the user clicks anywhere on the main window after a pop-up window is displayed the pop up goes to the background and when the user clicks on other "pop up window buttons" the pop up window does not come to the foreground unless it had been closed.  

QUESTION:
What can I add to the code so users will always get the pop up window in the foreground even if the previous window is lurking in the background.

------------------------------------
-------------------------------
Example#2

      <TD>
         <CENTER><FORM ACTION="" METHOD=POST name=myform>
            <P><INPUT TYPE=button NAME=Button1 VALUE="      Hardware      " onclick="window.open ('descript/hardware.htm', 'newWin', 'scrollbars=no,status=no,width=200,height=200')">
         </FORM></CENTER>
      </TD>
---------------------------
I would like my solution to work on 3.O browsers and above (it would be great to work on 2.0 and above
-------------------------------
-------------------------------
0
Comment
Question by:calley
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1277568
put this in the html code for the popup window
<body ... onLoad="this.focus()">
0
 

Author Comment

by:calley
ID: 1277569
sybe,

Please give me more direction on where to add your code:

put this in the html code for the popup window
    <body ... onLoad="this.focus()">

---------------------
Where does that go in the following code:

<FORM ACTION="" METHOD=POST name=myform>
                <P><INPUT TYPE=button NAME=Button1 VALUE="      Hardware      "
    onclick="window.open ('descript/hardware.htm', 'newWin',
    'scrollbars=no,status=no,width=200,height=200')">
             </FORM>
0
 

Expert Comment

by:btphelps
ID: 1277570
Focus() is not supported by IE.

Brian
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Expert Comment

by:btphelps
ID: 1277571
Focus() is not supported by IE.

Brian
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1277572
1. Alerts play sounds - that is what they are made for

2. you second example is ok, you need to put the following in the
descript/hardware.htm file:

<HTML>
<HEAD>
<TITLE>hardware<TITLE>
</HEAD>
<BODY ONLOAD="if (self.focus) self.focus(); else alert('Hardware');>

Here is all you ever wanted to know about hardware
</BODY>
</HTML>

The construction above will bring the window to front in NS2.x and up and MSIE 3.x and up

0
 

Author Comment

by:calley
ID: 1277573
I added the code suggested by mplungjan and got a syntax error.
---------------

Let me explain my problem more specifically and post the html files in question below.  Please load these files and try your solution out.  I would like the solution to work on Netscape 3.0 and above (Netscape 2.0 and above would be even better along with it working on IE 3.0 or above):

I have a main file (called start.htm) with 3 java buttons.  Each button take the user to a pop up window when clicked.  

The problem is that the pop up window does not stay on the top (forefront) after it first appears if at all.  If someone double clicks the button then the pop up window can't be seen as it is behind the main window (the second click does that).  Also if the user clicks anywhere else on the main window after a pop-up window is displayed, the pop up goes to the background and when the user clicks on other "pop up window buttons" the pop up window does not come to the foreground unless it had been closed.  

    QUESTION:
What can I add to the code so users will always get the pop up window in the foreground even if the previous window is lurking in the background or when the user clicks somewhere on the main winddow the pop up window does not go to the background?

Here are two files that will provide you with what you need to test your solution.  Thank you!

start.htm
--------------
<HTML>
<HEAD>
   <TITLE>Educational Resource Start Page</TITLE>
   <META NAME=GENERATOR CONTENT="Claris Home Page 3.0">
   <X-CLARIS-WINDOW TOP=42 BOTTOM=477 LEFT=4 RIGHT=534>
   <X-CLARIS-TAGVIEW MODE=minimal>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER><FONT SIZE="+2" COLOR="#FF0000"><B>Start
Page</B></FONT><TABLE BORDER=0 HEIGHT=128>
   <TR>
      <TD COLSPAN=3>
         <CENTER>Here are the categories to choose from:</CENTER>
      </TD>
   </TR>
   <TR>
      <TD>
         <P><FORM ACTION="" METHOD=POST name=myform>
            <CENTER><INPUT TYPE=button NAME=Button1 VALUE=" Software  " onclick="window.open ('software.htm', 'newWin', 'scrollbars=no,status=no,width=200,height=100')"></CENTER>
         </FORM></P>
      </TD>
      <TD>
         <P><FORM ACTION="" METHOD=POST name=myform>
            <CENTER><INPUT TYPE=button NAME=Button1 VALUE="      Hardware      " onclick="window.open ('hardware.htm', 'newWin', 'scrollbars=no,status=no,width=200,height=200')"></CENTER>
         </FORM></P>
      </TD>
      <TD>
         <P><FORM ACTION="" METHOD=POST name=myform>
            <CENTER><INPUT TYPE=button NAME=Button1 VALUE="Research" onclick="window.open ('research.htm', 'newWin', 'scrollbars=no,status=no,width=200,height=200')"></CENTER>
         </FORM></P>
      </TD>
   </TR>
 
</TABLE>
</CENTER>
</BODY>
</HTML>
------------
------------

hardware.htm
-----------
<HTML>
<HEAD>
   <TITLE>Hardware Description</TITLE>
   <META NAME=GENERATOR CONTENT="Claris Home Page 3.0">
   <X-CLARIS-WINDOW TOP=66 BOTTOM=480 LEFT=8 RIGHT=538>
   <X-CLARIS-TAGVIEW MODE=minimal>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<P><FONT SIZE="+1">Great hardware technology tools for educators:
Computers, PDA's, Printers, Scanners, Digital Cameras, modems,
etc.</FONT></P>

<P><FORM ACTION="" METHOD=POST>
   <CENTER><INPUT TYPE=button NAME=Button VALUE="Close" onclick="self.close()"></CENTER>
</FORM></P>
</BODY>
</HTML>
---------------

Thanks again!!


0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 120 total points
ID: 1277574
<BODY ONLOAD="if (self.focus) self.focus(); else alert('Hardware');">

Sorry I forgot a closing quote after alert('Hardware');"  

Michel
0
 

Author Comment

by:calley
ID: 1277575
Thank you!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question