Forum Moderators: open

Message Too Old, No Replies

Help to target main window from popup

Need information...

         

Texas

8:45 pm on Apr 19, 2002 (gmt 0)

10+ Year Member



Howdy Yall,

I'm using a popup (once per browser session) on my index page to optionally direct visitors to another page on the site. The problem though is that the link opens another window.

Does anyone know how i can target the main window already open only?

Additionally, is there a way to auto-close the popup after the link has been clicked?

<url snipped>

Any help much appreciated,

Texas

(edited by: tedster at 7:11 pm (utc) on April 20, 2002)

jatar_k

9:07 pm on Apr 19, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if the main page is the one that opens the popup you can use
parent.location = urlfrompopup;

txbakers

10:05 pm on Apr 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it's simple.

from your pop-up:

function GetAndClose() {
opener.location.href="newpage.htm";
window.close();

}

Texas

11:08 pm on Apr 19, 2002 (gmt 0)

10+ Year Member



Thanks for the replies people, however, I'm still stumped. Instead, let me show you what I'm using now.

Here is the script (in body of index page) which calls the popup (once per session)...

<script>

function openpopup(){
var popurl="http://example.com/page_pop.html"
winpops=window.open(popurl,"","width=260,height=200,")
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function loadornot(){
if (get_cookie('poppedup')==''){
openpopup()
document.cookie="poppedup=yes"
}
}

loadornot()
</script>

Now here is the html for the popup page...

<HTML>
<head>
<TITLE>Title</TITLE>
<STYLE>A { TEXT-DECORATION: underline }
</STYLE>

<STYLE>A:hover { COLOR: #FF0000; background-color: #FFFF00 }
</STYLE>
</head>
<BODY>
<table>
<tr>
<td>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#0000FF">
<div align="center">
<font color="#000000" size=2 face="arial"><p>Message text</p>
<p><font color="#000000" size=2 face="arial"><b> <a href="http://example.com/page_main.html" TARGET="main_window">Send it!</b></a></font>
<p>
<font size="-2">< <a href="javascript:self.close()">close window</a> ></font> </p>
</td>
</tr>
</table>

</BODY>
</html>

Again, my question is, how can I target the /page_main.html page without the link opening another window...and close the popup at the same time?

Texas

(edited by: tedster at 7:16 pm (utc) on April 20, 2002)

txbakers

2:57 am on Apr 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<p><font color="#000000" size=2 face="arial"><b> <a href="http://iexample.com/page_main.html" TARGET="main_window">Send it!</b></a></font>
<p>
<font size="-2">< <a href="javascript:self.close()">close window</a> ></font> </p>

Your problem is that there is no "main_window" since you are not using frames.

What I would do is as follows:
In the popup:
<a href="#" onClick="main()">Send it!</a>

Up in your head section have this function:

<script>
function main() {
opener.location.href="http://example.com/page_main.html";
window.close();

}
</script>

That's all there is to it.

(edited by: tedster at 7:18 pm (utc) on April 20, 2002)

Texas

12:05 am on Apr 21, 2002 (gmt 0)

10+ Year Member



Thanks Txbakers,

Your example worked like a charm. And in case anyone else is interested. Here's what I did...

Between head tags of popup:

<script>
function main() {
opener.location.href="http://inkprintercartridges.com/free-ink-coupon.html";
window.close();

}
</script>

For the link in the popup:

<a href="http://inkprintercartridges.com/free-ink-coupon.html" onClick="main()">Send it!</a>

See it in action here:

[inkprintercartridges.com...]

Again, many thanks.

Texas