SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Aug 2006
    Posts
    142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pop-up script with a variable from parent form

    Here is a neat little popup window script I like to use.

    Code:
    <script language="javascript" type="text/javascript">
    <!--
    var newwindow = '';
    
    function popitup_deletecounty(url) {
    	if (!newwindow.closed && newwindow.location) {
    		newwindow.location.href = url;
    	}
    	else {
    		newwindow=window.open(url,'deletecounty','height=200,width=250, left=230, top=348');
    		if (!newwindow.opener) newwindow.opener = self;
    	}
    	if (window.focus) {newwindow.focus()}
    	return false;
    }
    
    // -->
    </script>
    The html href looks like this

    PHP Code:
    <a href="/dataservices/geoeval_deletecounty.php?pjid=<?php echo $Request_ID;?>&id=<?php echo $Site_ID;?>&geid=<?php echo $GE_ID;?>"
    onClick="return popitup_deletecounty('/dataservices/geoeval_deletecounty.php?pjid=<?php echo $Request_ID;?>&id=<?php echo $Site_ID;?>&geid=<?php echo $GE_ID;?>')" 
    name="deletecounty" > delete </a>
    Can someone help me use the name attribute of the href in the javascript function, ie.

    function popitup_namevariable(url)?

    I'd like to make the script generic so I can just use it as a source instead of the whole thing and so I can use it multiple times in the same page with different links.

    I am new at this so if anyone can give me some pointers it would be much appreciated.

    Can someone help me to use t

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    like this?:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    
    	<head>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    		<title>Untitled Page</title>
    		<script type="text/javascript"><!--
    function newWin(myLink) {
    	var winName = "window_" + myLink.name;
    	var winUrl = myLink.href;
    	
    	if (document[winName]) {
    		if (document[winName].location != winUrl) document[winName].location.href = winUrl;
    	} else {
    		document[winName] = window.open(winUrl,winName,'height=200,width=250, left=230, top=348');
    		if (document[winName].opener) document[winName].opener = self;
    	}
    
    	if (window.focus) document[winName].focus();
    	
    	return false;
    
    }
    //-->
    </script>
    	</head>
    
    	<body>
    		<a href="http://www.google.com" onclick="newWin(this); return false;" name="googleWindow">Click</a>
    		<a href="http://www.yahoo.com" onclick="newWin(this); return false;" name="yahooWindow">Click</a>
    		<a href="http://www.wired.com" onclick="newWin(this); return false;" name="wiredWindow">Click</a>
    	</body>
    
    </html>
    Last edited by funkdaddy; Jan 24, 2007 at 14:24. Reason: added location checking for old windows


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
  •