Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Location.Href of a Popup Window

Posted on 2006-03-31
5
Medium Priority
?
446 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.
0
Comment
Question by:j0kStA
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:Lakio
ID: 16346726
<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
 
LVL 1

Author Comment

by:j0kStA
ID: 16346785
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
 
LVL 9

Accepted Solution

by:
Lakio earned 1000 total points
ID: 16346908
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
 
LVL 1

Author Comment

by:j0kStA
ID: 16346962
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
 
LVL 9

Expert Comment

by:Lakio
ID: 16347142
or action ;) no problem m8
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question