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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to get a jumpmenu to open in specified new window

    I have a web page with many links opening in a new window. The opening of this new window is governed by a JS Function that I wrote:

    function newWindow(bookjpg) {
    bookWindow = window.open(bookjpg, "bookWin", "toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=870,height=8 00")
    bookWindow.focus()
    }
    This is workign perfectly for all the links on the page-opening in the correct window. But, I have a jumpmenu that also links to various parts of my site that I want to be governed by this same newWindow function. Of course, it is not and I do not know how to integrate these two functions. Here is the code for the jumpmenu:

    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }

    and here is the code that calls this function in the body:

    onChange="MM_jumpMenu('newWindow()',this,0)">

    As you can see I have substituted 'newWindow' for the target info. This is not working. (This was my best guess at trying to make this work). When I test this in the browse I get the error 'undefined' is null or not an object. I think it is stemming from the eval() part of the jumpmenu code.

    Any thoughts?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,030
    Thanks
    0
    Thanked 247 Times in 244 Posts
    Put a target parameter in the newWindow function.
    Code:
    function newWindow(bookjpg, target) {
      var bookWindow = window.open(bookjpg, target, "toolbar=yes,location=yes,status=yes,menubar=yes,sc rollbars=yes,resizable=yes,width=870,height=800");
      bookWindow.focus();
    }
    
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      newWindow(selObj.options[selObj.selectedIndex].value, targ);
      if (restore) selObj.selectedIndex=0;
    }
    ...
    onChange="MM_jumpMenu('mywin',this,0)"
    then change the call to newWindow by all the links to:

    newWindow('url', 'bookWin')

    But if you want all the links and the pages in the option items opened to the same popup window, the targ parameter in the call to the MM_jumpMenu function on onchange event, should be the same with that of the links:

    onChange="MM_jumpMenu('bookWin',this,0)"

  • #3
    New to the CF scene
    Join Date
    May 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    glenngv,
    You pretty much rock!!!!!!
    That saved me about 20 hours of pulling my hair out.

    Thanks much


  •  

    Posting Permissions

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