Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I create a pop-up on my page.

    I have a question? How do you make a page (When Opened) open up into a smaller box compared to taking up the entire window. Basically I need to know how to create a popup window for my page to remind users of new features. Would I need to use Java or something and what would the code look like? My page is written in HTML. Any help would be greatly appreciated
    Last edited by npala2001; 07-09-2004 at 03:56 PM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    The basic codeis

    window.open('url','window name','attributes')

    So using a button would go

    <input type="button" Value="Open New Window" ONCLICK="window.open('targetpage.htm','win1','width=300,height=300')">

    and as a link

    <A HREF="#null" ONCLICK="window.open('Your Page.htm', 'win2','width=300,height=100,left=450,top=250,toolbar=yes')">Your Link</A>

    For more information see here

    http://www.huntingground.freeserve.c...dow/newwin.htm

  • #3
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Great, It worked!!! thanks for your help

  • #4
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    One more question is there a way to have a button to close a window and if so what would it look like?

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Would this button be in the parent or the popup?

  • #6
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Parent page is where I wanted the close window feature. I found it on that website link you gave me. Now is there a way to code it so that it does not give the prompt "The webpage you are viewing is trying to close the window". Other than that the code below works great.

    Close Window Code:
    <A HREF="#null" onclick="window.close(-1); return false"></A>

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    In order to reference the popup from the parent you have to give the popup a name.


    <a href="#null" onclick="mywin=window.open('yourpage.htm','','left=200,top=200,width=300,height=300')">Open</a>


    <a href="#null" onclick="mywin.close()">Close</a>

  • #8
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want the user to have the ability to close the main page itself. Would I need in essence to turn the main page into a pop-up and reference the main page name then use the close feature?

  • #9
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    The following is classed as a work round to suppress the message shown when trying to close the parent window in that instance.

    The script is placed in the parent page

    <script>

    function close_win(){
    window.opener = top;
    window.close()
    }

    </script>


    <a href="#null" onclick="close_win()">Close</a>
    Last edited by Mr J; 07-10-2004 at 12:33 PM.

  • #10
    New Coder
    Join Date
    Jul 2004
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For a second there it was no working then I looked at what the function the link was calling and there was a "." were a "_" was supposed to be. I got it to work, It works great thanks for all of your help.

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts

    Just a note...

    As Mr. J pointed out, that's a workaround. He's right because that's actually a bug exploit. Meaning, it might not work in the future if the bug is fixed.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •