/    Sign up×
Community /Pin to ProfileBookmark

Hi,

How do you create a link that closes the current window and opens another?

Thanks ya’ll

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@CAT_web_designOct 11.2005 — [B]Does This Help?[/B] -

[code=html]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Open & Close</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body>
<a href="#" onMouseDown="MM_openBrWindow('http://www.yoursite.com','WindowName','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=width(px),height=height(px)')" onMouseUp="window.close()">Close Window</a>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@jamOct 11.2005 — even if you can get a good script^^^^ most browsers like ie6+ ask you weather you would like to close the window which is annoying.....Why not use the window.location thing
Copy linkTweet thisAlerts:
@comptech520authorOct 11.2005 — This is what I have:

It gives me an error, and does not work properly. DO any of you gues know the answer?
[code=html]


<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>

<a href="#" onMouseDown="MM_openBrWindow('http://www.djshawnmichaels.com/ml/newsletters.php','DJSM Newsletter','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=no,width=600,height=300,left=300,top=300')" onMouseUp="window.close()">Join</a>[/code]
Copy linkTweet thisAlerts:
@comptech520authorOct 11.2005 — Actually, I have this working now after playing with it for a bit. My New question is:

going to http://djshawnmichaels.com/popup2.php

Click on join, the top window is suppose to close, but doesen't.

Could you please help me trouble shoot?

[code=html]
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>


<a href="#" onMouseDown="MM_openBrWindow('http://www.djshawnmichaels.com/ml/newsletters.php','WindowName','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=300,left=300,top=300')" onMouseUp="window.close()">Join</a>
[/code]

Thank you ?
Copy linkTweet thisAlerts:
@bathurst_guyOct 11.2005 — Its working for me in Firefox 1.0.6, though newsletter.php isn't loading. But I'm just guessing it doesnt exist yet.

All I can think of atm is that onMouseUp, if say you click on it and not release but drag off this will not be called. You can place both of these things in the same action, preferably an onClick.

eg.

onClick="MM_openBrWindow('http://www.djshawnmichaels.com/ml/newsletters.php','WindowName','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=300,left=300,top=300'); window.close();"
Copy linkTweet thisAlerts:
@comptech520authorOct 11.2005 — genius you are ? Thank you
×

Success!

Help @comptech520 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...