SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member Daem0n's Avatar
    Join Date
    Aug 2003
    Location
    Greece
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Will it work with Javascript?

    Hi,
    I made a change on my site and I came across a problem which I believe it can be fixed with a small Javascript code. But I really don't have a clue regarding what the code should look like and I thought I'd ask here.

    So...
    I have a popup page with a comment form where I'd like it to open a new blank window while in the mean time to close the popup (with the comment form) when I press the submit button.

    It's a bit confusing so let me explain exactly what the whole thing does.
    The popup page comes in standard size, it displays the comments of a news post and contains a form for sending new comments. If I send a new comment the page that will load doesn't fit to the excisting size of the current popup window. So when I hit the submit button (to send the comment), I'd like it to close the current popup and open a new window that will contain the new page with the posted comments.

    Doesn't anyone have any ideas about how to make the above thing work?
    Thanks in advance!

  2. #2
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try this:
    Code:
    <form method="post" action="pagetopostto" target="newwin" onSubmit="window.open('', 'newwin', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=505,height=400'); window.close();" name="theForm">
    You can try that and see how it works for you; just change the height and width to your needs!

  3. #3
    SitePoint Member Daem0n's Avatar
    Join Date
    Aug 2003
    Location
    Greece
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much kgh!
    I'm going to try it as soon as I get home!

  4. #4
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It would be better if you made a function containing the code window.open etc, called, say, myOpener() and then just have onSubmit="myOpener()" instead of the long string with the obvious possibility of typos. Then you can use the function on other pages as well. And when editing your code, it is easier to read as the long string doesn't get in the way.

  5. #5
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya, true


Bookmarks

Posting Permissions

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