#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    31
    Rep Power
    13

    javascript function opens a file in another window


    I have a button with a function:

    function goToURL() { window.location = "cart.htm"; }

    This button is in a popup window. I want this button to open the location(cart.htm) inside the frame: "main" in the primary window(the window under)

    How can this be done?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    function goToURL() {
    opener.top.main.location = "cart.htm";
    }
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    31
    Rep Power
    13
    It wont work....
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    20
    try
    Code:
    function gotoURL() {
    parent.main.location.href = 'cart.htm';
    }
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    function goToURL() {
    opener the window that opened the pop-up
    .top the <frameset> page in that window
    .main a <frame> in the <frameset> (name="main")
    .location its location property (displayed page)
    = "cart.htm"; the URL
    }

    If it 'doesn't work' - it's because your description left something out. Many of the objects you reference in JavaScript are created in HTML - they're two sides of the same coin. Without the HTML, it's just a guessing game as to what's there...

IMN logo majestic logo threadwatch logo seochat tools logo