[英]Link from other site should open the first link of the site
Have a look at the site below, will delete it later:- 看看下面的网站,将在以后删除: -
[Career page][1] [职业页] [1]
On this page, if I come from other website like Facebook/ Linked in, it should look like this:- 在这个页面上,如果我来自Facebook / Linked等其他网站,它应该是这样的: -
![Image 1][2] ![图片1] [2]
And If I visit from the same site, it should be like below:- 如果我从同一个网站访问,它应该如下: -
here is my JS code related to that. 这是我的JS代码。 Please suggest what to do:-
请建议做什么: -
function pageLoad() {
$("#careerdiv").accordion({
collapsible: true,
autoHeight: false,
active: false
});
$("a#various15").fancybox({
'width': 720,
'height': 390,
'autoScale': false,
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'type': 'iframe',
'speedIn': 600,
'speedOut': 400,
'overlayShow': true,
'overlayOpacity': 0.8,
'overlayColor': '#000',
'padding': '0px',
'onComplete': function () { $('.closer').click(function () { parent.$.fancybox.close(); }) }
});
}
Please suggest what to do 请建议做什么
if (document.referrer.indexOf('facebook.com') > -1) {
// do something for visitors from facebook here
}
You can use document.referrer
. 您可以使用
document.referrer
。 Here is a contrived example: 这是一个人为的例子:
$(document).ready(function() { var referrer = document.referrer; if(referrer.match(/stackoverflow.com/i)){ // change this to the name of your site $('#targetDiv').show(); // change this line as needed for you actual page } else{ $('#targetDiv2').show(); // remove this line for you actual page // $('.ui-accordion-header').eq(0).click(); // uncomment this line for your actual page } });
.none{ display:none; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="targetDiv" class="none">You see this, so you came from SO</div> <div id="targetDiv2" class="none">You see this, so you came from a site other than SO</div>
You just have to check if referrer is from fb || 你只需要检查引用者是否来自fb || li and open accordion number 1 I guess:
李和开放手风琴1号我猜:
if( document.referer ){
$("#careerdiv").accordion({
collapsible: true,
autoHeight: false,
active: 1
} else {
$("#careerdiv").accordion({
collapsible: true,
autoHeight: false,
active: false
});
}
Can you please change the following of your code: 您能否更改以下代码:
$("#careerdiv").accordion({
collapsible: true,
autoHeight: false,
active: false
});
with the following (of which host check taken from here ): 以下(从这里获取主机检查):
if( document.referrer.indexOf(location.protocol + "//" + location.host) === 0){
$("#careerdiv").accordion({
collapsible: true,
autoHeight: false,
active: false
});
} else{
$("#careerdiv").accordion({
collapsible: true,
autoHeight: false,
active: 0
});
}
which checks if the referrer is you own host and activates the first accordion which has the index 0
(in zero based index). 检查引用者是否是你自己的主机并激活第一个具有索引
0
手风琴(基于零的索引)。 Remember to test it on the server. 记得在服务器上测试它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.