We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Location.Href of a Popup Window

j0kStA
j0kStA asked
on
Medium Priority
939 Views
Last Modified: 2006-11-18
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.
Comment
Watch Question

Commented:
<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>

Author

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.
Commented:
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)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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.

Commented:
or action ;) no problem m8
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.