在具有元刷新(时间= 0秒)的页面上,运行< Head>中的分析javascript? [英] On a page with a meta refresh (with time=0 seconds) run the analytics javascript in the <Head>?

查看:88
本文介绍了在具有元刷新(时间= 0秒)的页面上,运行< Head>中的分析javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果标记末尾有Google Analytics(分析).js调用,并且我有一个meta刷新标记(在0秒内刷新)以将页面重定向到另一个网站,则.js每次都能正常运行还是有机会在.js运行之前以某种方式重定向页面?

If I have the Google Analytics .js call at the end of the tag, and I have a meta refresh tag (refresh in 0 seconds) to redirect the page (to another site), will the .js run OK every time or is there a chance the page will somehow redirect before the .js runs?

(我的理解是,.js本质上是异步运行的,因此答案应该是是,.js将始终运行.但要检查.")

(My understanding is that the .js essentially runs asynchronously so the answer should be Yes, the .js will always run. But wanted to check.)

推荐答案

首先看 时间= 0秒 它可能会/可能不会导致执行,可能是第0次机会(没有机会) 浏览器应在0秒内重新加载当前页面

firstly look time=0 seconds,so, it may/may not cause an execute , probably 0th chance (No chance) the browser should reload the current page in 0 seconds

以及使用元刷新标签的一些缺点

and some Drawbacks to Using Meta Refresh Tags

元刷新标签有一些缺点:


元刷新重定向已被垃圾邮件发送者用来欺骗搜索引擎.因此,搜索引擎会将那些网站从其数据库中删除.如果您使用大量的元刷新标签来重定向页面,搜索引擎可能会确定您的网站为垃圾邮件,并将其从其索引中删除.最好改用301服务器重定向.

如果重定向迅速发生(少于2-3秒),则使用旧版浏览器的读者将无法点击返回"按钮.这是一个可用性问题.
如果重定向快速发生并转到不存在的页面,则读者可能会陷入循环,而看不到404页面以外的任何内容.发生这种情况时,大多数人只是放弃并离开,而不是试图弄清楚您要带他们去哪里.
刷新当前页面可能会使人们感到困惑.如果他们不要求重新加载,某些人可能会担心安全性.


Meta refresh redirects have been used by spammers to fool search engines. So search engines remove those sites from their database. If you use a lot of meta refresh tags to redirect pages, the search engines may decide your site is spam and delete it from their index. It’s better to use a 301 Server Redirect instead.

If the redirect happens quickly (less than 2-3 seconds), readers with older browsers can’t hit the "Back" button. This is a usability problem.
If the redirect happens quickly and goes to a non-existant page, your readers may get stuck in a loop without seeing any content other than a 404 page. When this happens, most people simply give up and leave rather than trying to figure out where you were trying to take them.
Refreshing the current page can confuse people. If they didn’t request the reload, some people can get concerned about security.

为什么您超时使用javascript?

why wint you use javascript with a time out?

    <script language="javascript" type="text/javascript">
   setTimeout(function () {
       window.location.href = "tea.html"; //will redirect to your blog page (an ex:                  tea.html)
    }, 2000); //will call the function after 2 secs.
    </script>

这篇关于在具有元刷新(时间= 0秒)的页面上,运行&lt; Head&gt;中的分析javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆