SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Refreshing parent window?

    Hi Guys,

    Need a bit of help here...
    I am opening a new window using this code:

    PHP Code:
    echo "<a href='../cart/phpcart.php?state=$_SESSION[state]&action=add&id=$productCode&descr=$description&price=$price&quantity=1' target='new' class='cart'>
    <img src='../images/trolley.gif' border='0' />&nbsp;Add to cart</a>"

    On the window that pops up a have a link to close the window:
    PHP Code:
    <a href="javascript:window.close();" class=headings title='continue shopping'>Continue Shopping</A
    Upon clicking continue shopping I would like the window to close and the parent (1st page) to refresh.

    How would I do this?

  2. #2
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I know target="new" isn't valid HTML, so I'm guessing the window that 'pops up' is just a regular browser window. Since you didn't create this window via js I'm not sure you can close it at all using the window.close method > if you did it would most likely cause the entire browser to close - not good!

    If my assumption above is correct then it would seem you need to use the window.open or similar method to initially open that window and then do some kind of window.parent function to refresh the other window.

  3. #3
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply

    OK I have replaced target="new" with:

    PHP Code:
    <script language="javascript">

    /*
    Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
    */

    var win null;
    function 
    NewWindow(mypage,myname,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/0;
    TopPosition = (screen.height) ? (screen.height-h)/0;
    settings =
    'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    win window.open(mypage,myname,settings)
    }

    </script> 
    I am using this to open the new window:

    PHP Code:
    echo "<a href='../cart/phpcart.php?state=$_SESSION[state]&action=add&id=$productCode&descr=$description&price=$price&quantity=1' class='cart' onclick=\"NewWindow(this.href,'cart','800','600','yes');return false\"> 
    Can anyone possibly tell me how I could modify this link to close the popup and refresh the parent window?

    PHP Code:
    <a href="javascript:window.close();" class=headings title='continue shopping'>Continue Shopping</A

  4. #4
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PLease... Can anyone help me with this?


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
  •