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
    dmk
    dmk is offline
    New Coder
    Join Date
    Aug 2002
    Location
    Wisconsin, USA
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Opening link in New Window, with JavaScript

    On our Intranet, I have a series of drop-down menus in Frame 2. Each link opens in Frame 3. A few months ago, I needed to add a menu item to Frame 2 that had to open in a New Window (instead of in Frame 3) and I got some help on that. Now I need to add another menu item that must open in a New Window, but I don't know how to amend the code (please see below) to do that. Thanks.

    This shows the code that forces the Expense Report to open in a new window:
    Code:
    <script LANGUAGE="JavaScript">
    <!-- 
    function JumpToIt (list) 
    { 
    	var selection = list.options[list.selectedIndex].value 
    	if (selection != "NewWindow") { 
    	parent.body.location.href = selection 
    }else{ 
    window.open("http://dk_intranet/FinanceDept/ExpenseRpt.xls","def") 
    } 
    list.selectedIndex=0 
    }
    
    
    //-->
    This is the code of the actual drop-down menu where the Expense Report choice exists:

    Code:
    <form>
    	<select WIDTH="1" onChange="JumpToIt(this)" size="1" name="Finance" style="font-family: Arial; font-size: 8pt; position: relative; float: left; width: 150">
    
    
    	<option VALUE="http://dk_intranet/link_pg_finance_dept.htm" selected>Finance Department
    ---&gt;
    	<option VALUE="http://dk_intranet/FinanceDept/BillCover.pdf">Bill Cover Ltr Instructions</option>
    	<option VALUE="http://dk_intranet/FinanceDept/Work Assignmt.htm">Billing/Attorney Assignments</option>
    	
    	<option VALUE="NewWindow">Expense Report</option>
    
    
    	<option VALUE="http://dk_intranet/FinanceDept/GBMileage.pdf">Green Bay Mileage Chart</option>
    	</select></form>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could try this:
    <html>
    <head>
    <title>Test</title>
    <script LANGUAGE="JavaScript">
    function JumpToIt (list)
    {
    var selection = list.options[list.selectedIndex].value.split("|")
    if(selection[0]=="frame")
    {
    parent.main.location.href = selection[1]
    }
    else
    {window.open(selection[1],"def")}
    list.selectedIndex=0
    }
    </script>
    </head>
    <body>
    <form>
    <select WIDTH="1" onChange="JumpToIt(this)" size="1" name="Finance" style="font-family: Arial; font-size: 8pt; position: relative; float: left; width: 150">
    <option VALUE="frame|http://dk_intranet/link_pg_finance_dept.htm" selected>Finance Department</option>
    <option VALUE="frame|http://dk_intranet/FinanceDept/BillCover.pdf">Bill Cover Ltr Instructions</option>
    <option VALUE="frame|http://dk_intranet/FinanceDept/Work Assignmt.htm">Billing/Attorney Assignments</option>
    <option VALUE="NewWindow|http://dk_intranet/FinanceDept/ExpenseRpt.xls">Expense Report</option>
    <option VALUE="frame|http://dk_intranet/FinanceDept/GBMileage.pdf">Green Bay Mileage Chart</option>
    </select></form>
    </body>
    </html>

    In the value property for each option tag you specify if it is to open in a frame or a new window. You separate that from the link with a pipes "|" character (or another that you like) and then in the function you split the two values to create a two dimensional array. Then do the checking. I named my frame "main" because a frame name of "body" might cause problems. Hope this helps and good luck.

  • #3
    dmk
    dmk is offline
    New Coder
    Join Date
    Aug 2002
    Location
    Wisconsin, USA
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! That worked. If I have to add another entry that should open in a new window, do I just have to add
    Code:
    NewWindow|
    to the option value instead of
    Code:
     <option Value="frame|...?


  •  

    Posting Permissions

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