/    Sign up×
Community /Pin to ProfileBookmark

Close Window HELP

Hi all,

I have the following pages which are configured in a FRAMESET.

FRAMESET CODE:

<html>
<head>
<title>External Link</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<frameset rows=”60,*” framespacing=”0″ marginheight=”0″ marginwidth=”0″ frameborder=”0″ margin=”0″ border=”0″ cols=”*“>
<frame src=”../Admin/TOPFRAME.htm” name=”top” scrolling=”NO” noresize marginheight=”0″ marginwidth=”0″>
<frame src=”http://www.hmce.gov.uk” name=”mainFrame” marginheight=”0″ marginwidth=”0″ >
<noframes>
</noframes> </frameset>
</html>

TOP FRAME:

<html>
<head>
<title>External Link Top Frame</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>

<script language=”JavaScript”>
<!–
function close_window() {
window.close();
}
//–>
</script>
</head>

<body bgcolor=”#FFFFFF” text=”#000000″ background=”../images/Background.gif”>
<table width=”100%” border=”3″ bordercolor=”#990000″>
<tr>
<td width=”68%”><img src=”../images/retrun.gif” width=”251″ height=”44″ usemap=”#Map” border=”0″></td>
<td width=”32%”>
<div align=”right”><img src=”../images/homepage.gif” width=”236″ height=”33″ align=”top”></div>
</td>
</tr>
</table>
<map name=”Map”>
<area shape=”rect” coords=”106,24,155,35″ target=”_parent” onMouseOver=”close_window()”>
</map>
</body>
</html>

BOTTOM FRAME: [I]This is an external link[/I]

The FRAMESET works OK. But when I click on the CLOSE Gif on the TOP FRAME the window does not close.

If I run the page from the TOP FRAME as a standalone page the CLOSE works OK.

Can anyone see what is wrong with it.

REMEMBER IT IS A FRAMESET WITH 2 FRAMES:

TOP FRAME LOADS PAGE TOPFRAME.HTM AND THE BOTTOM
FRAME LOADS AN EXTERNAL LINK.

Many thanks if you can help.

Regards

Dereck

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@CharlesJan 10.2003 — [font=georgia]Try using [font=monospace]top.close()[/font] instead of your [font=monospace]close_window()[/font].[/font]
Copy linkTweet thisAlerts:
@pyroJan 10.2003 — Or better yet, leave your close_window() function and change window.close() to top.close() in your function.
Copy linkTweet thisAlerts:
@CharlesJan 10.2003 — [i]Originally posted by pyro [/i]

[B]Or better yet, leave your close_window() function and change window.close() to top.close() in your function. [/B][/QUOTE]
[font=georgia]Why is that better? It needlessly takes up name space and garbage collection time.[/font]
Copy linkTweet thisAlerts:
@pyroJan 10.2003 — [i]Originally posted by Charles [/i]

[B][font=georgia]Why is that better? It needlessly takes up name space and garbage collection time.[/font] [/B][/QUOTE]
Aren't you not supposed to execute javascript commands directly from the link?
Copy linkTweet thisAlerts:
@dcjonesauthorJan 10.2003 — Hi Guys, now don't fall out :-)

Charles. I have amended the script to

<html>

<head>

<title>External Link Top Frame</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript">

<!--

function top.close() {

window.close();

}

//-->

</script>

</head>

<body bgcolor="#FFFFFF" text="#000000" background="../images/Background.gif">

<table width="100%" border="3" bordercolor="#990000">

<tr>

<td width="68%"><img src="../images/retrun.gif" width="251" height="44" usemap="#Map" border="0"></td>

<td width="32%">

<div align="right"><img src="../images/homepage.gif" width="236" height="33" align="top"></div>

</td>

</tr>

</table>

<map name="Map">

<area shape="rect" coords="106,24,155,35" href= onClick="top.close()" target="_parent">

</map>

</html>


BUT where is says - href= onClick="top.close()" target="_parent" - this statement does close the FRAMESET but tries to open - onClick="top.close()"


Any thoughts.

And thanks for your time.

Regards

Dereck
Copy linkTweet thisAlerts:
@CharlesJan 10.2003 — [font=georgia]Where did you hear that? And what do you think [font=monospace]onMouseOver="close_window()"[/font] is if it's not "execut[ing] javascript commands directly from the link?[/font]
Copy linkTweet thisAlerts:
@pyroJan 10.2003 — I heard it from someone on these forums. I guess I should have checked into it before I said that, as I really am not sure. Sorry.

Also, dcjones this line

<area shape="rect" coords="106,24,155,35" href= onClick="top.close()" target="_parent">

has a few syntax errors, try this

<area shape="rect" coords="106,24,155,35" href="#" onClick="top.close()">

and remove your javascript from the head, or change the function name to something like function top_close() and then change the command inside the function to top.close(). Now you will just have to call your function from the link like this onClick="top_close()". Either method will work.

Oh, by the way, Charles, top_close() is calling a function, while top.close() is executing the command.
Copy linkTweet thisAlerts:
@WebskaterJan 10.2003 — You now appear to be issuing the command "top.close()" and trying to call a function of the same name?

Why not just tell it what to do without calling a function. In your situation I use:

onclick="javascript:window.parent.close();" and it works every time.
Copy linkTweet thisAlerts:
@pyroJan 10.2003 — onClick="top.close()" works fine, if he removes the function named that...
Copy linkTweet thisAlerts:
@dcjonesauthorJan 10.2003 — Guys, it work fine following what Pyro has said.

Many thanks to you all for your help on this.

If your ever in Warwickshire England I will buy you a pint.

Thanks

Dereck
×

Success!

Help @dcjones 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 4.27,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...