/    Sign up×
Community /Pin to ProfileBookmark

How to close popup window?

I know this is probably very basic…

I found the code that will cause another page to appear in a popup window when a visitor clicks on a link, but I can’t find the code to put in the popup window that will allow someone to click on Close to close the popup.

So in summary, what do I need to put in a popup window that will allow it to be closed by clicking on a text link in the window.

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 29.2004 — should the link be in the "root" window or in the popup window?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 29.2004 — [CODE]
<html>
<head>
<title>close window</title>
<head>
<body>
<!-- this only works in IE -->
<a href="javascript:window.close();">Close Window</a>
</body>
</html>
[/CODE]
Copy linkTweet thisAlerts:
@baseiberDec 29.2004 — There are a few different ways to do this.

Here's a site that might help you with this

[URL=http://www.devguru.com/home.asp]devguru.com[/URL]

Look under javascript and objects.

I'll try to give you a hint. You want a [B]window[/B] to [B]close[/B].


auh u gave it to him!
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 29.2004 — u wanted him to guess it?
Copy linkTweet thisAlerts:
@baseiberDec 29.2004 — no but it's usually best when they learn on their own.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYDec 29.2004 — yeah right...excuse me:p
Copy linkTweet thisAlerts:
@tx858authorDec 29.2004 — Thanks for the script but I need something not limited to IE. So [B]before[/B] I look at devguru I guess I should ask - does a script exist like this that'll work in other browsers too?

As is obvious, I just started learning javascript - took the basic lessons on this site last night and I think it was a good start.

Thanks!
Copy linkTweet thisAlerts:
@baseiberDec 29.2004 — DevGuru tests IE and Netscape and marks if it only works with IE or Netscape.

You could try self.close. It works in IE. I'm not sure about other browsers.
Copy linkTweet thisAlerts:
@d333muApr 18.2006 — help please i am having trouble on one thing only, if this complete the form is finished, what i am trying to do is when user clicks on submit on form a popup window appers and whitin this popup window i wand another button so when user clicks this button it closes the popup window


****************************************************************

<html>

<head>

<script type="text/javascript">

var dogPhoto = "";

function displayPhoto(nPhoto){

if (nPhoto == ""){return}

var currPhoto = nPhoto;

if (dogPhoto != ""){dogPhoto.close()}

dogPhoto = window.open('','','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,hei ght=300,left = 262,top = 134');

dogPhoto.document.open();

var imgStr = "<img src="+currPhoto+">"

dogPhoto.document.write(imgStr);

dogPhoto.document.close();

}


var dogs = [];

dogs[0] = ['s','s','l',false,'bully.jpg','Bully'];

dogs[1] = ['s','s','h',true,'rex.jpg','Rex'];

dogs[2] = ['s','l','l',true,'daisy.jpg','Daisy'];

dogs[3] = ['m','s','h',true,'dot.jpg','Dot']; // same as licorice

dogs[4] = ['l','l','l',true,'sam.jpg','Sam'];

dogs[5] = ['l','s','h',true,'pip.jpg','Pip'];

dogs[6] = ['s','l','l',false,'cyril.jpg','Cyril'];

dogs[7] = ['l','s','l',true,'bones.jpg','Bones'];

dogs[8] = ['m','s','h',true,'liquorice.jpg','Licorice']; //same as dot

dogs[9] = ['l','s','h',false,'fang.jpg','Fang'];

function buildList(nName,nPhoto){

var nOption = document.createElement('option');

var isData = document.createTextNode(nName);

nOption.setAttribute('value',nPhoto);

nOption.appendChild(isData);

document.forms[1]['matched'].appendChild(nOption);

}

function chooseDog(nForm){

if (dogPhoto != ""){dogPhoto.close()}

document.forms[1]['matched'].options.length = 1;

var nSize = nForm['size'].value;

var nCoat = nForm['coat'].value;

var nEnergy = nForm['energy'].value;

if (nSize == "" || nCoat == "" || nEnergy == "")

{alert('Select from all lists'); return}

var nChild = false;

if (document.getElementsByName('child')[0].checked){nChild = true}

var n = 0;

for (i=0; i<dogs.length; i++)

{

if (nSize == dogs[i][0] && nCoat == dogs[i][1] && nEnergy == dogs[i][2] && nChild == dogs[i][3])

{

buildList(dogs[i][5],dogs[i][4])

}

}

if (document.forms[1]['matched'].length == 1)

{alert('No Matches Found')}

}



</script>

</head>

<body>



<form>

<fieldset align='center' style='font-size:12pt;width:625px;padding:5px'>

<legend style='font-size:14pt;color:darkblue;padding:3px'> Choose a dog</legend>



<label>Select its size

<select name="size">

<option value=""> Choose </option>

<option value="l">Large </option>

<option value="m">Medium </option>

<option value="s">Small </option>

<option value="d">Any </option>

</select>

</label>



&nbsp;&nbsp



<label> Select its coat

<select name="coat">

<option value=""> Choose </option>

<option value="s">Short </option>

<option value="l">Long </option>

<option value="d">Any </option>

</select>

</label>



&nbsp;&nbsp



<label> Select its level

<select name="energy">

<option value=""> Choose </option>

<option value="h">High Energy </option>

<option value="l">Low Energy </option>

<option value="d">Any </option>

</select>

</label>



<br><br>



<label> Should the dog be good with children? </label>

<label> Yes <input type="radio" NAME="child"> </label>

<label> No <input type="radio" NAME="child" checked> </label>



<br><br>



<input type="button" value="Submit" onclick="chooseDog(this.form)">

&nbsp;&nbsp;

<INPUT TYPE=reset>

</fieldset>

</form>



<form>

<fieldset align='center' style='font-size:12pt;width:625px;padding:5px'>

<legend style='font-size:14pt;color:darkblue;padding:3px'> Matched Dogs</legend>



<select name='matched' onchange="displayPhoto(this.value)">

<option value=""> Select to View a Photo </option>

</select>

</fieldset>

</form>



</body>

</html>
Copy linkTweet thisAlerts:
@James_GatkaApr 18.2006 — Stop doing this. Check the other threads you've replied to or started. Stop spamming.
×

Success!

Help @tx858 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.18,
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,
)...