我的页面底部有一个旋转木马,有3个youtube视频。 有一个Twitter按钮可以分享这些个人视频。
当您点击推特按钮时,您将获得如下链接: http://yoursite.com/index.html#video-1
因此链接会指向页面底部。 但是,我试图找出伪代码和逻辑,指向页面底部,并旋转到正确的视频。
此刻, http://yoursite.com/index.html#video-1 http://yoursite.com/index.html#video-2 http://yoursite.com/index.html#video-3
都将指向#video-1
答案 0 :(得分:0)
我已经弄明白了。
基本上,只需在URL中进行字符串检测即可解决问题。
// Check the URL for a given # anchor string
if(document.URL.indexOf("buying-a-car") != -1) {
$("#YTvideo"+1).show();
} else if(document.URL.indexOf("taking-a-holiday") != -1){
$("#YTvideo"+2).show();
} else if(document.URL.indexOf("moving-to-new-zealand") != -1){
$("#YTvideo"+3).show();
} else if(document.URL.indexOf("selling-your-house") != -1){
$("#YTvideo"+4).show();
} else{
$("#YTvideo"+1).show();
}