Question

I have a problem with this code in Safari (in Firefox and Chrome it works)

When I load the page, in the file created rows are duplicated. If you reload the page without closing the browser tab the script works well.

I attach a video to better understand

$fileName = 'test.txt';
$d = date("d/m/Y - H:i:s");
echo $d . "<br>\n";
echo '------------------------------------------' . "<br>\n";

file_put_contents($fileName, $d . PHP_EOL, FILE_APPEND);

$lines = file($fileName);
foreach($lines as $lineNum => $line) {
    echo "Line #" . ++$lineNum . " : " . $line . "<br />\n";
}
Was it helpful?

Solution

From Apple:

Engineering has determined that this issue behaves as intended based on the following:

This occurs because we preload Top Hits in the background when it appears likely that they'll be selected from the completion list. This behavior can be disabled from Safari's Privacy preference pane via the "Do not preload Top Hit in the background" checkbox.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top