繁体   English   中英

为来自特定站点的访问者显示特定内容

[英]Display specific content for visitors coming from specific sites

对于同一个网站(html),我需要根据它们来自哪里(推荐人)来显示特定的内容。

例子:

在 0.html 里面,我们有类似的东西:

<html>
<content for visitors from example1.com>
<content for visitors from example2.com>
</html>

所以:

访客 1 点击来自 example1.com 的链接指向 otherexample.com/0.html --> 仅显示

<content for visitors coming from example1.com>

访客 2 单击来自 example3.com 的链接指向 otherexample.com/0.html --> 仅显示

<content for visitors coming from example2.com>
  1. javascript/html可以做到这一点吗?
  2. 使用此规则在 0.html 内显示 external.html 怎么样?

找到了解决方案:

    <script>
var ref = document.referrer;
if (ref.match(/^https?:\/\/([^\/]+\.)?subdomain\.example\.com(\/|$)/i)) {
   document.write('<img src="https://example.com/img/logo.png" width="60%">');
}
    </script>

这将仅为来自特定子域的访问者加载图像。

显示特定的<div> setTimeout() 处的内容</div><div id="text_translate"><p>在下面的代码中,我正在使用setTimeout()对我的后端 node.js 应用程序进行 API 调用,该应用程序每 5 秒调用一次我的 AJAX。 在我的 AJAX 成功中,我根据应至少执行一次的特定条件显示divContent1和divContent2 。 之后,在每个setTimeout()调用中,只有divContent2应该是可见的。</p><p> <strong>索引.html</strong></p><pre> &lt;script type="text/javascript"&gt; $(document).ready(function(){ $.ajax({ url: "http://localhost:8070/api/route1", type: 'POST', dataType:'json', success: function(res) { //Some Task } }); $("#myButton").click(function(){ const route2 = function() { $.ajax({ url: "http://localhost:8070/api/route2", type: "POST", dataType: "json", data: { var1: val1 }, success: function (res) { // Various tasks if(res.flag){ $("#divContent1").hide(); $("#divContent2").show(); } else{ $("#divContent1").show(); } //Functions that handle div content data }, beforeSend: function() { $("#divContent1").hide(); $("#divContent2").hide(); }, complete: function() { setTimeout(route2,5000); }, }); }; $(function(){ route2(); }) }); }); &lt;/script&gt;</pre><p> setTimeout() 调用整个route2来处理div内容的所有显示和插入。 但是,要求仅显示第二次调用的divContent2 。</p><p> 寻找解决方案</p></div>

[英]Display a specific <div> content at setTimeout()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 仅向来自 facebook 的访问者展示广告 仅当来自特定链接时才在页面上显示div 在打印中显示特定div的内容 显示特定内容onclick 显示特定的<div> setTimeout() 处的内容</div><div id="text_translate"><p>在下面的代码中,我正在使用setTimeout()对我的后端 node.js 应用程序进行 API 调用,该应用程序每 5 秒调用一次我的 AJAX。 在我的 AJAX 成功中,我根据应至少执行一次的特定条件显示divContent1和divContent2 。 之后,在每个setTimeout()调用中,只有divContent2应该是可见的。</p><p> <strong>索引.html</strong></p><pre> &lt;script type="text/javascript"&gt; $(document).ready(function(){ $.ajax({ url: "http://localhost:8070/api/route1", type: 'POST', dataType:'json', success: function(res) { //Some Task } }); $("#myButton").click(function(){ const route2 = function() { $.ajax({ url: "http://localhost:8070/api/route2", type: "POST", dataType: "json", data: { var1: val1 }, success: function (res) { // Various tasks if(res.flag){ $("#divContent1").hide(); $("#divContent2").show(); } else{ $("#divContent1").show(); } //Functions that handle div content data }, beforeSend: function() { $("#divContent1").hide(); $("#divContent2").hide(); }, complete: function() { setTimeout(route2,5000); }, }); }; $(function(){ route2(); }) }); }); &lt;/script&gt;</pre><p> setTimeout() 调用整个route2来处理div内容的所有显示和插入。 但是,要求仅显示第二次调用的divContent2 。</p><p> 寻找解决方案</p></div> 使用自定义选择显示特定内容 如果存在具有特定类别的div,则显示内容 如何跟踪来自AdWords的访问者 如何知道游客来自哪里? 尝试在特定站点上加载动态内容而不影响其他站点
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM