搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

video set to autoplay causes hit counter to double count

more options

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

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

被選擇的解決方法

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

從原來的回覆中察看解決方案 👍 0

所有回覆 (19)

more options

Can you post a link to a page that demonstrates this behavior?

more options
more options

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.

more options

j - when you say "fix", do you mean change the poster "." to poster "" ? if so, i just tried it and got the same behavior.

more options

選擇的解決方法

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

more options

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 ?

more options

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. ;-)

more options

ok. thanks again.

more options

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.

more options

ok. i will try and find the exact text. that advice is very much appreciated.

more options

12345

由 pat500 於 修改

more options

12345

由 pat500 於 修改

more options

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 :

&lt!DOCTYPE html&gt
&lthtml lang="en"&gt
&lthead&gt
<meta charset="UTF-8">
<title>DRAGON ART STORE - Home Page</title>
if i understand you correctly, it would be better like this :

&lt!DOCTYPE html&gt
&lthtml lang="en"&gt
&lt?php
header('Content-type: text/html; charset=utf-8');
?&gt
<head>
<title>DRAGON ART STORE - Home Page</title>

is that what you had in mind ?

由 pat500 於 修改

more options

12345

由 pat500 於 修改

more options

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.

more options

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 ?

&lt?php
header('Content-type: text/html; charset=utf-8');
?&gt
&lt!DOCTYPE html&gt
&lthtml lang="en"&gt

<head>
<title>DRAGON ART STORE - Home Page</title>

more options

Yes, that should work.

more options

hmm. i got this error message at the top. i don't know what it means. would you have a look ?

att

more options

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.