SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question iframes and popups

    I have been trying to open a popUp window from an iframe on a page. The system is for reminders and prints the reminder in the iframe but I also want to do the same in a popUp. The pop up is triggered from an onload function with in the iframe (using php and mysql to determine whether or not it needs to be launched).

    My problem is that the popUp window is popping up with the iframe and not as a window of it's own. Here is the code I am using:

    function openPopWindow(r_id){
    in_height = 230;
    in_width = 300;
    name = "popUp";
    var page = "reminders/reminder_pup.html?id=" + r_id;
    win = window.open(page, name, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=' + in_width + ',height=' + in_height);
    win.focus();
    }

    Any help greatly received

    lorez

  2. #2
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe the problem is using 'name' as the variable. It must be a reserved word or one with a special meaning in JS, because if I use your code with a different variable, say 'tempName' it works.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a great illustration of why using undeclared variables will eventually get you into trouble. Your 'name' variable should be local to the function - it has no use beyond the scope of the function itself. Nevertheless, you didn't explicitly declare it:

    var name = "popUp";

    ...so it automatically becomes global in scope. Guess what? There already is a window.name property, and it serves as target for, among other things, the window.open() function. Are you with me so far? So, immediately after naming the window (iframe), you're targeting a new document into it.

    In other words: working perfectly!
    ::: certified wild guess :::

  4. #4
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Guys it worked. Thanks

    lorez


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
  •