Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 02-14-2006, 06:45 PM Self closing window
Average Talker

Posts: 27
Location: CT
Trades: 0
This might sound like a wierd question, but is there a way to automatically have a popup window close as soon as it opens?

I have a popup that triggers a PHP download, and opens it into MS Excel, then I'd like the window that launched the download to automatically close.

I've tried everything I can think of:
<body onload="self.close()">
<body onblur="self.close()">
<body onload="document.close()">


I'm out of ideas...

Just incase this matters, here's the complete page code:
<?php

require_once ('include/mysql_connect.php');

$select = "SELECT * FROM vehicles where status = 'Active' or status = 'Pending'";
$export = mysql_query($select);
$fields = mysql_num_fields($export);

for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($export, $i) . "\t";
}

while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);

if ($data == "") {
$data = "\n(0) Records Found!\n";
}

header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=Inventory.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";

?>

<html>
<head>
</head>
<body onload="self.close()">
&nbsp;
</body>
</html>
DBookatay is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-14-2006, 11:14 PM Re: Self closing window
CAL
CAL's Avatar
DudeWorldOrder.com

Posts: 684
Location: DudeWorldOrder.com
Trades: 1
You could try this

Code:
<SCRIPT>
   var howLong = 5000;
   t = null;
   function closeMe(){
   t = setTimeout("self.close()",howLong);
   }
   </SCRIPT>
This will close your window after 5 seconds. You can change it for your own specifications....

Also, your examples should look like:
<body onload=self.close();>
<body onblur="self.close();>
<body onload="document.close();>
__________________

Please login or register to view this content. Registration is FREE

Last edited by CAL; 02-14-2006 at 11:17 PM..
CAL is offline
Reply With Quote
View Public Profile Visit CAL's homepage!
 
Reply     « Reply to Self closing window
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12997 seconds with 12 queries