Click to See Complete Forum and Search --> : Link in popup-window...
nebulous
08-29-2003, 04:09 AM
Hi there!
How to make the following:
1) click link in main-window
2) opens popup
3) click link in popup
4) closes popup and opens link in main-window
I hope someone can held me!
:)
hammerslane
08-29-2003, 05:16 AM
to open the pop up window put this into the <HEAD> tag of your page
<script language="javascript" type="text/javascript">
<!--
/****************************************************
Author: Eric King
Url: http://redrival.com/eak/index.shtml
This script is free to use as long as this info is left in
Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',l ocation=yes,directories=no,status=yes,menubar=yes,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}
// -->
</script>
put this where you want the clickable link to appear in the MAIN WINDOW...
<a href="SOURCE OF POPUP PAGE" onclick="NewWindow(this.href,'PAGE NAME GOES HERE','500','500','yes','center');return false" onfocus="this.blur()">YourLinkText</a>
now, in the popup window put this code where you'd like the link to appear to close the window:
<a href='javascript:window.close();'>Close the window</a>
someone else will have to help you with double linking (so that when you click the CLOSE button, it also displays another page in the MAIN window....)
i hope you understand all this... :)
nebulous
08-29-2003, 05:24 AM
Ok, thanks a lot so far! The most tricky one is how to give the main window the new URL, I guess. Let's wait for some ideas...
hammerslane
08-29-2003, 10:41 AM
i've been wondering how to get a javascript link to do two links at once... can anyone help me and buddy here out?
halifaxrick
08-29-2003, 11:21 AM
A. if you know the name of the original window you could make it change url from a different window.
B. to get two or more actions from a single clik use the onclick parameter in addition to the href.
hammerslane
09-01-2003, 10:11 AM
<HTML>
<HEAD>
<TITLE>FRAME 10</TITLE>
<SCRIPT language="JavaScript">
<!----hide
function change2()
{
parent.left_frame.location="page3.htm";
parent.right_frame.location="page4.htm";
}
//------>
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF" text="#000000">
<CENTER>
Click the link below to change both frames.
<BR>
<A HREF="javascript:change2()">Change 2 Frames</A>
</CENTER>
</BODY>
</HTML>
this isn't really what you're after i dont think, but its helped me with a problem i had before (of similar nature to yours).
EDIT
<A HREF="newpage.htm" onClick='java script:window.close();'>is a simpler way to do two links in one click, as halifaxrick said.
nebulous
09-04-2003, 10:03 AM
I figured it out myself how to open the link in the previous browser window and close the current pop-up:
<a href="javascript:top.window.opener.top.location.href='yoursite.html'; window.close();">link</a>
That's it :)