Location.Href of a Popup Window

OK, here's the thing. I have a window that is opening a popup by way of form with a target tag. It must be done this way because the popup is an external site that needs the form data. The name I am giving the new window is "newwin". Is there a way to change the location.href attribute of the popup window from the parent doing this? I tried newwin.location.href, parent.newwin.location.href, newwin.document.location.href all to no avail. I know that normally you would specify a variable using var mywindow = window.open("","newwin") then say mywindow.location.href="". I also know that you can direct to a frame by using parent.frame1.location.href="". Not sure how to use the window name to refer to a popup. Please help.
LVL 1
j0kStAAsked:
Who is Participating?
 
LakioCommented:
ok,
I made two ways for you (desperately trying to get a A)

<html>
<form name='myform' action="http://www.google.com" method="POST" target="newwin">
<input type='hidden' value='something'>
</form>
<script language="JavaScript">
//document.myform.action="http://www.yahoo.com";
document.myform.submit();
//window.open("http://www.yahoo.com", "newwin");
</script>
</html>

just del the // in front the one you like (Im guessing window.open)
0
 
LakioCommented:
<html>
<head>
<title>Lakio's popup location thing</title>
<script type="text/javascript">
function popme(x){
if(x) {newwin.location="http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21797371.html";}
else {newwin=window.open("", "newwin","width=350,height=300");}
}
</script>
</head>
<body>
<a href="#" onclick="popme(0);return false">1. Open</a> | <a href="#" onclick="popme(1);return false">2. new location for that popup</a>
</body>
</html>
0
 
j0kStAAuthor Commented:
OK, I think my question may have been a bit confusing. I have a page similar to the following:

<html>
<form name='myform' action="http://www.google.com" method="POST" target="newwin">
<input type='hidden' value='something'>
</form>
<script language="JavaScript">
document.myform.submit();
newwin.location.href="http://www.yahoo.com"
</script>
</html>

It's the newwin.location.href="http://www.yahoo.com" that doesn't work. Is there a way to change the location.href of the window by just using the window name? You can do it with an href by doing the following <a href="http://www.yahoo.com" target="newwin">Click Here</a>, but I need it to redirect without having to click a link.
0
 
j0kStAAuthor Commented:
Perfect! I can't believe I didn't think about using window.open. I was so hung up on the location.href deal that I didn't think about other option. Thanks.
0
 
LakioCommented:
or action ;) no problem m8
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.