Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

pop up windows

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
calley
Asked:
calley
  • 3
  • 2
  • 2
  • +1
1 Solution
 
sybeCommented:
put this in the html code for the popup window
<body ... onLoad="this.focus()">
0
 
calleyAuthor Commented:
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
 
btphelpsCommented:
Focus() is not supported by IE.

Brian
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
btphelpsCommented:
Focus() is not supported by IE.

Brian
0
 
Michel PlungjanIT ExpertCommented:
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
 
calleyAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
<BODY ONLOAD="if (self.focus) self.focus(); else alert('Hardware');">

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

Michel
0
 
calleyAuthor Commented:
Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now