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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Popup window in javascript?

    I have a jsp page with button(worklistManager.jsp)... in button on click, am calling one function(getModify()) which is inside js file(utility.js).. inside that function, am doing some action and forwarding that values to next jsp page(modify.jsp) using window.location.href... the modify.jsp page should open as popup window... when i click button, it has to call the function and open the modify.jsp page as popup window... how to get this...

    worklistManager.jsp:

    Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <script src="script/Utility.js" data-dojo-config="parseOnLoad: true"></script>
    </head>
    <body>
    <div dojotype="dijit.MenuBarItem" id="SearchMenu21" onclick="getModify();" style="font-size:11pt;" title="menuBarItem">
                   <img class="images" id="SearchMenu21" name="search5.png" onclick="setImgProperty(this.id)" src="images/uploads/search.png" style="height:20px; width:20px;">
                   Modify
    </div>
    </body>
    </html>
    utility.js file:

    Code:
    function getModify(){
    	var whereCondn = "";
    	//alert(gbshowgridFlag);
    	if(dijit.byId('dynamicgridCWPROCESS')){
    		var selctedItem = dijit.byId('dynamicgridCWPROCESS').selection.getSelected();
    	    if(selctedItem.length){
    	    	dojo.forEach(selctedItem, function(selectedItem){
    	    		if(selectedItem !== null){
    	    			dojo.forEach(dijit.byId('dynamicgridCWPROCESS').store.getAttributes(selectedItem), function(attribute){
    	    				var value = dijit.byId('dynamicgridCWPROCESS').store.getValues(selectedItem, attribute);
    	    				//alert(value);
    	    				if(attribute == "PROCESS_ID"){
    	    					whereCondn = whereCondn+attribute+"="+value;
                  		  	}
    	    				//alert("new alert"+whereCondn);
    	    				window.location.href = "modify.jsp?DETAIL="+whereCondn;
    	    			});
    	    		}
    	    	});
    	    	//alert("grid row selected");
    	    }else{
    	    	alert("grid row not selected");
    	    }
    	}
        if(gbshowgridFlag==false){
        	alert("grid not loaded");
        }
    }

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Location
    London
    Posts
    152
    Thanks
    4
    Thanked 42 Times in 42 Posts
    Replace this line -
    Code:
    window.location.href = "modify.jsp?DETAIL="+whereCondn;
    with -
    Code:
    window.open("modify.jsp?DETAIL="+whereCondn,'modifyPage','height=600px,width=800px,scrollbars=no,sizable=yes,toolbar=no,statusbar=no');

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,616
    Thanks
    0
    Thanked 645 Times in 635 Posts
    That suggests opening in a popup - it doesn't force the browser to do so - each visitor still has the choice of opening in the same or a new tab instead just as they do with the original code which simply suggests opening in the same tab.

    Which of the three possible locations a new page opens is always under the control of your visitor.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    New Coder
    Join Date
    Dec 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by niralsoni View Post
    Replace this line -
    Code:
    window.location.href = "modify.jsp?DETAIL="+whereCondn;
    with -
    Code:
    window.open("modify.jsp?DETAIL="+whereCondn,'modifyPage','height=600px,width=800px,scrollbars=no,sizable=yes,toolbar=no,statusbar=no');

    its working... thanks niralsoni... how to get the popup window in center of the page..


  •  

    Tags for this Thread

    Posting Permissions

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