PDA

View Full Version : New windows



robjime
Feb 9th, 2005, 11:25 PM
I want to, when the user clicks on a link open a window, which i was successful with, then the user inputs info into two boxes and when they click submit it put that info into a box on the parent page. Im having trouble with getting the boxes into the comment form. Heres my code:

Index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ipod Game</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
function link(mypage,myname,w,h,features) {
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
function insertlink(ltit, lurl) {
nlink = "<a href=" + ltit + ">" + lurl + "</a>";
document.fnote.content.value=document.fnote.content.value+nlink;
document.fnote.content.focus();
win.window.close();
}
</script>
</head>

<body>
<p><a href="#" onClick="link('link.htm', 'wlink', '325','125', '')">Link</a> <a href="#" onClick="link('song.htm', 'song', '325', '125', '')">Song</a>
</p>
<form name="fnote" method="post" action="">
<label>
<textarea name="content" id="content"></textarea>
</label>
</form>
<p>&nbsp; </p>
</body>
</html>


new window(link.htm)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Link</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="lform" >
<table width="300" height="97" border="0" cellspacing="1">
<tr bordercolor="#0066FF" bgcolor="#0066FF">
<td><font color="#FFFFFF">Link Url</font></td>
<td> <input type="ltitle" name="textfield">
browse</td>
</tr>
<tr bordercolor="#0066FF" bgcolor="#0066FF">
<td><font color="#FFFFFF">Link Text</font></td>
<td> <input type="ltext" name="textfield2"> </td>
</tr>
<tr bordercolor="#0066FF" bgcolor="#0066FF">
<td height="27" colspan="2"><div align="center">
<label>
<input type="submit" name="Submit" value="Go" onClick="insertlink(win.lform.ltitle.value, win.lform.ltitle.value)">
</label>
</div></td>
</tr>
</table>
</form>
</body>
</html>

Willy Duitt
Feb 12th, 2005, 07:17 PM
Try: onclick="opener.insertlink(win.lform...

And without a live link I am not even involving myself in the win variable which may also be creating another problem once you properly call the function from the parent document...

.....Willy

robjime
Feb 13th, 2005, 11:34 PM
opener.form.etc works in IE but how do i address the parent window in mozilla/firefox.

Willy Duitt
Feb 14th, 2005, 12:55 AM
opener works in ff as well... your problem probably goes back to the second issue I noted...

robjime
Feb 14th, 2005, 04:16 PM
probably should've mentioned this before, when using firefox the error returned is opener.fnote has no properties, but it works fine in IE.

Willy Duitt
Feb 14th, 2005, 05:39 PM
probably should've mentioned this before, when using firefox the error returned is opener.fnote has no properties, but it works fine in IE.

yep... That would be part of the second issue I noted...

robjime
Feb 14th, 2005, 08:44 PM
how do i fix this, or what do you suggest