Current location: Hot Scripts Forums » General Community » Script Requests » script for auto-close on click


script for auto-close on click

Reply
  #1 (permalink)  
Old 08-07-03, 04:13 AM
kasperzonderondergoed's Avatar
kasperzonderondergoed kasperzonderondergoed is offline
Newbie Coder
 
Join Date: Aug 2003
Location: Belgium
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
script for auto-close on click

I need a script that closes a window with an image, text, video, ... when you try to click on it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-07-03, 04:57 AM
Henry's Avatar
Henry Henry is offline
Wannabe Coder
 
Join Date: Jul 2003
Location: Brisbane, Australia
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Im guesing you mean when some one right clicks but if you mean when some one clicks on something and the window closes thats the script there (oh and replace hello with the image or whatever):

<html>
<head>
<title>hello</title>
<script language=javascript>
function closewindow()
{
close()
}

</script>

</head>
<body>
<a onclick="closewindow()">hello</a>
</body>
</html>

if you want it to run on a right click do this:

<html>
<head>
<title>hello</title>
<script language=javascript>
function closewindow()
{
window.close()
}
</script>

</head>
<body oncontextmenu="closewindow()">
text
</body>
</html>

this should work i hope i havent tried it if it doesnt just tell me!
__________________
henerz
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-07-03, 05:14 AM
kasperzonderondergoed's Avatar
kasperzonderondergoed kasperzonderondergoed is offline
Newbie Coder
 
Join Date: Aug 2003
Location: Belgium
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
thanks, that's exactly the script i need!
Thank you very much!
greetz,
Kasper
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-07-03, 05:16 AM
kasperzonderondergoed's Avatar
kasperzonderondergoed kasperzonderondergoed is offline
Newbie Coder
 
Join Date: Aug 2003
Location: Belgium
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
is it possible to edit so it works when you click on it and rightclick it? (so, both scripts at the same time)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 08-07-03, 05:24 AM
Mat Mat is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
I would think you just not use the script at all the achive that.

-Mat
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 08-07-03, 05:24 AM
kasperzonderondergoed's Avatar
kasperzonderondergoed kasperzonderondergoed is offline
Newbie Coder
 
Join Date: Aug 2003
Location: Belgium
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
for php it will give something like:
PHP Code:

<?php

echo "<HTML>\n";
echo 
"<HEAD>\n";
echo 
"<TITLE>hello</TITLE>\n";
echo 
"<script language="JavaScript"\n";
echo 
"function closewindow()\n";
echo 
"{\n";
echo 
"close()\n";
echo 
"}\n";
echo 
"</script>\n";
echo 
"</HEAD>\n";
echo 
"<BODY>\n";
echo 
"<a onclick="closewindow()">hello</a>\n";
echo 
"</BODY>\n";
echo 
"</HTML>\n"
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 08-07-03, 12:05 PM
MadDog MadDog is offline
Code Master
 
Join Date: Aug 2003
Posts: 935
Thanks: 0
Thanked 0 Times in 0 Posts
You guys are adding way to much code, use the following,

Code:
<a href="JavaScript:window.close()">Close Window</a>
__________________
Drew Gauderman
ASP - MSSQL Coder / Buisness Owner / Coder for Hire!
MSN-ICQ-AIM-YIM in Profile

http://www.iportalx.net an easy ASP portal system.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 08-07-03, 09:54 PM
etLux etLux is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
You might go see the Fat Guy over at www.CodeBelly.com -- specifically, "Closing Windows From Java Script: Six Methods" at

http://codebelly.com/javascript/closingwindows.html

That gives you all the basics... including short code snippets to do the job.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a good review management script griz_fan Script Requests 10 07-29-07 06:08 AM
Do you know this script? amandad Script Requests 3 09-30-03 11:55 AM
Question of the Day script? ncasares PHP 4 08-26-03 08:58 PM
Talkback script..help pls BC_ PHP 0 06-22-03 07:44 PM
Need help with a script boardpix PHP 7 06-09-03 12:37 AM


All times are GMT -5. The time now is 01:56 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.