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

Posts: 27
Location: CT
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
 
When You Register, These Ads Go Away!
Old 02-14-2006, 10:14 PM Re: Self closing window
CAL
CAL's Avatar
DudeWorldOrder.com

Latest Blog Post:
Men Bashing Jokes
Posts: 684
Location: DudeWorldOrder.com
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();>
__________________
Dude World Order

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

Thread Tools

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

vB 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.12510 seconds with 12 queries