Skip to content

Commit ca949b9

Browse files
committed
Fixed #54
1 parent 57db948 commit ca949b9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

demo/shot.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
$fileLocation = 'test';
4242
$screen->save($fileLocation);
4343

44+
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
45+
header("Pragma: no-cache"); // HTTP 1.0.
46+
header("Expires: 0"); // Proxies.
4447
header('Content-Type:' . $screen->getImageType()->getMimeType());
4548
header('Content-Length: ' . filesize($screen->getImageLocation()));
4649
readfile($screen->getImageLocation());

templates/screen-capture.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@
1414
page.settings.resourceTimeout = <?php echo $timeout ?>;
1515
<?php endif ?>
1616

17-
page.open('<?php echo $url ?>', function () {
17+
page.open('<?php echo $url ?>', function (status) {
18+
if (status !== 'success') {
19+
console.log('Unable to load the address!');
20+
phantom.exit(1);
21+
}
1822

1923
<?php if (isset($includedJsScripts)) : ?>
2024
<?php foreach ($includedJsScripts as $script) : ?>
2125
page.injectJs('<?php echo $script ?>');
2226
<?php endforeach ?>
2327
<?php endif ?>
2428

25-
/* This will set the page background color white */
2629
page.evaluate(function() {
2730
<?php if (isset($backgroundColor)) : ?>
28-
document.body.bgColor = '<?php echo $backgroundColor ?>';
31+
/* This will set the page background color */
32+
if (document && document.body) {
33+
document.body.bgColor = '<?php echo $backgroundColor ?>';
34+
}
2935
<?php endif ?>
3036

3137
<?php if (isset($includedJsSnippets)) : ?>

0 commit comments

Comments
 (0)