N-son tabbed/JsScrollbar,尝试使用jquery通过点击链接强制播放gif

发布于 2024-08-28 16:36:53 字数 710 浏览 3 评论 0原文

让我首先陈述显而易见的事情;我是新来的。也就是说,我希望我发布此内容不会违反我错过的一些标准。 xD

几天来,我一直在尝试更新我的一个相当旧的网站,由于更新幅度太大,我寻求您帮助的当前产品与旧网站并不相似,因此我不会链接到该网站以任何其他方式然后外观。

任何人!我正在使用 N-son 创建的选项卡式 div 和 JsScrollbar (http://www. downloadjavascripts.com/list/javasitek60/Details.aspx),到目前为止仅使用 jquery 动态居中页面上的内容。

然而我的问题是......我在页面上有一个 gif 用作背景(它不是平铺的),我希望能够拥有它,这样当您单击 n- 中使用的链接之一时sons 选项卡(例如:新闻)它还会导致 gif 加载并自行播放一次。

到目前为止,我自己完成此任务的所有尝试都失败了,并且破坏了滚动条或阻止您单击选项卡时切换内容。 (除了一次失败的尝试之外,一切都工作正常,除了滚动条的手柄在切换选项卡时会消失)

我希望我已经清楚这一点并且有人能够提供帮助。我知道这似乎是一个愚蠢的问题,但在某些时候我们都是新的。 :P

如果需要的话,我会上传我拥有的代码,但它并不漂亮。

先感谢您。

Let me start off by stating the obvious; I am new here. That said I hope I am not violating some standard I missed by posting this. xD

For several days now I've been trying to update a rather old site of mine, to which I wont link to given that the update is so drastic that the current product on which I seek your help for doesn't resemble the old site in any other way then appearance.

Anywho! I am using the tabbed div and JsScrollbar created by N-son (http://www.downloadjavascripts.com/list/javasitek60/Details.aspx) and so far have only used jquery to dynamically center content on the page.

My problem however is this...I have a gif on the page that acts as a background (it's not tiled) and I'd like to be able to have it so that when you click on one of the links used in n-sons tabs (EX: news) it also causes the gif to load and play through itself once.

So far all my attempts at accomplishing this myself have failed and break wither the scrollbar or prevent the content from switching when you click the tabs. (Except for one failed attempt where it all worked fine except the handle for the scrollbar would vanish upon switching tabs)

I hope I've been clear in this and that someone is able to help. I know it may seem like a silly question but we're all new at some point. :P

If need be I'll upload what coding I have but it is not pretty.

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁年轻赶紧闹 2024-09-04 16:36:54

我不确定我更改了什么,以便它不再中断,但下面的代码可以解决问题。如果你们中有人知道如何将其浓缩,我们将不胜感激。

    <script type="text/javascript">
var scroller  = null;
var scrollbar = null;

window.onload = function () {
  scroller  = new jsScroller(document.getElementById("News"), 400, 180);
  scrollbar = new jsScrollbar (document.getElementById("Scrollbar-Container"), scroller, true, scrollbarEvent);
}

function scrollbarEvent (o, type) {
    if (type == "mousedown") {
        if (o.className == "Scrollbar-Track") o.style.backgroundColor = "none";
        else o.style.backgroundColor = "none";
    } else {
        if (o.className == "Scrollbar-Track") o.style.backgroundColor = "none";
        else o.style.backgroundColor = "none";
    }
}

function swapIt(o) {
    o.blur();
    if (o.className == "current") return false;

    var list = document.getElementById("Navigation").getElementsByTagName("a");
    for (var i = 0; i < list.length; i++) {
        if (list[i].className == "current") {
            list[i].className = "";
            document.getElementById(list[i].title).y = -scroller._y;
        }
        if (list[i].title == o.title) o.className = "current";
    }

    list = document.getElementById("Container").childNodes;
    for (var i = 0; i < list.length; i++) {
        if (list[i].tagName == "DIV") list[i].style.display = "none";
    }

    var top = document.getElementById(o.title);
    top.style.display = "block";
    scrollbar.swapContent(top);
    if (top.y) scrollbar.scrollTo(0, top.y);

    return false;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>

I'm not sure what I changed so that it doesnt break anymore but the code below does the trick. If any of you know how to condense this down, it'd be greatly appreciated.

    <script type="text/javascript">
var scroller  = null;
var scrollbar = null;

window.onload = function () {
  scroller  = new jsScroller(document.getElementById("News"), 400, 180);
  scrollbar = new jsScrollbar (document.getElementById("Scrollbar-Container"), scroller, true, scrollbarEvent);
}

function scrollbarEvent (o, type) {
    if (type == "mousedown") {
        if (o.className == "Scrollbar-Track") o.style.backgroundColor = "none";
        else o.style.backgroundColor = "none";
    } else {
        if (o.className == "Scrollbar-Track") o.style.backgroundColor = "none";
        else o.style.backgroundColor = "none";
    }
}

function swapIt(o) {
    o.blur();
    if (o.className == "current") return false;

    var list = document.getElementById("Navigation").getElementsByTagName("a");
    for (var i = 0; i < list.length; i++) {
        if (list[i].className == "current") {
            list[i].className = "";
            document.getElementById(list[i].title).y = -scroller._y;
        }
        if (list[i].title == o.title) o.className = "current";
    }

    list = document.getElementById("Container").childNodes;
    for (var i = 0; i < list.length; i++) {
        if (list[i].tagName == "DIV") list[i].style.display = "none";
    }

    var top = document.getElementById(o.title);
    top.style.display = "block";
    scrollbar.swapContent(top);
    if (top.y) scrollbar.scrollTo(0, top.y);

    return false;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文