video set to autoplay causes hit counter to double count
on my website i have a video set to play immediately (set to autostart). but for some reason, when viewing in FF, this makes my .php hit counter increment by 2 (or sometimes even 4).
on other pages that have videos that are played manually, the hit counter works fine. but if i add autoplay video, the counter goofs up.
chrome doesn't have this problem on any pages, nor does IE. i have reset FF to factory. v13.0.1
Izabrano rješenje
No, I mean change your PHP so that if there is no actual separate poster image, you do not include the poster attribute at all. It isn't necessary if you want the first frame of the video displayed. See: https://developer.mozilla.org/en/HTML/Element/video
Pročitajte ovaj odgovor sa objašnjenjem 👍 0All Replies (19)
Can you post a link to a page that demonstrates this behavior?
glad to. dragonartstore.com/test
In your page, you have this (line breaks added for readability):
<video height="170" preload="auto" autoplay="autoplay" poster "*.*">
Firefox interprets that as follows (select page > right-click > View Selection Source):
<video tabindex="0" preload="auto" autoplay="autoplay" poster="" "*.*"="" height="170">
As you can see, Firefox sets poster="" which you probably had no idea causes Firefox to retrieve the page itself as the image. I'm not sure what Firefox is doing with the "*.*" but again it appears to be interpreting it as something that takes a URL and is again retrieving the page.
Can you fix this tag in your PHP?
That add up to 3 page retrievals. I think I've left one unaccounted for, but maybe fixing this will take care of that one as well.
j - when you say "fix", do you mean change the poster "." to poster "" ? if so, i just tried it and got the same behavior.
Odabrano rješenje
No, I mean change your PHP so that if there is no actual separate poster image, you do not include the poster attribute at all. It isn't necessary if you want the first frame of the video displayed. See: https://developer.mozilla.org/en/HTML/Element/video
hey, that seemed to work.
sometime back, when i was first learning html5 (only about 4 months ago), i discovered that using poster "." did something very neat, and i was proud that i had discovered the trick. but now i don't remember what it was.
your explanation makes a lot of sense.
i am appreciative.
being that this was my first post, i will ask a dumb question. if for some reason it starts to goof up again, is there a way i can ask you directly ?
I generally check this site every day, but if you really need to contact me directly, I'm pretty easy to track down in Google. ;-)
ok. thanks again.
One other thing to look at is specifying your character encoding in an HTTP header sent before Firefox actually starts parsing the document. This has been reported as an issue in some shopping cart applications: failure to do this can cause Firefox to re-request (re-submit a request) when it comes to the meta tag specifying the character set.
You can try this at the top of your file with any other headers you are setting:
<?php header('Content-type: text/html; charset=utf-8'); ?>
If I've remembered that incorrectly, you can get the precise syntax by searching around.
ok. i will try and find the exact text. that advice is very much appreciated.
12345
Izmjenjeno
12345
Izmjenjeno
j - i have read your suggestion several times, and i can't say that i completely understand it. "specifying your character encoding in an HTTP header sent before Firefox actually starts parsing the document. This has been reported as an issue in some shopping cart applications: failure to do this can cause Firefox to re-request (re-submit a request) when it comes to the meta tag specifying the character set. "
i can't tell from these words whether it should be done or not (this has been reported as an issue & failure to do so ...).
this is what is currently at the top of my page :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DRAGON ART STORE - Home Page</title>
if i understand you correctly, it would be better like this :
<!DOCTYPE html>
<html lang="en">
<?php
header('Content-type: text/html; charset=utf-8');
?>
<head>
<title>DRAGON ART STORE - Home Page</title>
is that what you had in mind ?
Izmjenjeno
12345
Izmjenjeno
Sorry, I assumed your site is PHP-based; if you are using a content management system or another publishing platform, or JSP or ASP, then there would be a different way to do this.
The PHP code should be the first first three lines on the document. It generates a header that is sent to the browser ahead of the page and is not part of the page that you can see in the browser.
my site was originally sitename.html, but i had to change it to sitename.php in order to get the PHP hit counter to work. but i am not sure if that makes it PHP-based.
is this what you have in mind ?
<?php
header('Content-type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>DRAGON ART STORE - Home Page</title>
Yes, that should work.
hmm. i got this error message at the top. i don't know what it means. would you have a look ?
att
Hi pat500, it means that the way your server is configured, you can't add the header I suggested adding. Sorry! You could contact your host and request that they add it to your server's configuration files so it is sent automatically. But since this is only to try to avoid problems with the hit counter, I'm not sure it's worth paying for support for that.