문제

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";
}
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top