如何解决SP中断的Javascript问题 [英] How to fix a Javascript issue that SP is interrupting

查看:217
本文介绍了如何解决SP中断的Javascript问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一个不错的幻灯片,并将其添加到我的网站中.很抱歉,由于它是一个私人网站,因此无法在此处发布指向它的链接.无论如何,这是使它起作用的代码:

  • var 1 函数 功能 var var " mySlides" 如果 1 如果 1 for 0 无" 1 "block""

    最奇怪的是.当我使用上面的代码以及CSS和HTML时,它在SharePoint以外的地方都可以很好地工作.滑块不会自动工作;您必须单击向左或向右箭头才能手动将其推进 我想要的.但是,当我采用相同的代码,并使用内容编辑器和脚本编辑器Web部件将其集成到SharePoint页面中时,除一件事情外,其他所有东西都可以正常工作.

     

     

    通过查看JS,任何人都可以看到我可以在哪里调整该代码,以便它不会像原来一样反弹-即使不在SP中时它也不会反弹?奇怪,我知道,但只是希望有人能帮助我.

    解决方案

    我的猜测是n设置为x + 1,然后跳回幻灯片1.找出n是否被SharePoint更改了??


    I have a nice little slideshow I got and added to my site.  I'm sorry I cannot post the links to it here as it's a private site.  Anyway, here is the code that makes it work:

    1. <script>  
    2. var slideIndex = 1;  
    3. showDivs(slideIndex);  
    4.   
    5.   
    6. function plusDivs(n) {  
    7.   showDivs(slideIndex += n);  
    8. }  
    9.   
    10.   
    11. function showDivs(n) {  
    12.   var i;  
    13.   var x = document.getElementsByClassName("mySlides");  
    14.   if (n > x.length) {slideIndex = 1}      
    15.   if (n < 1) {slideIndex = x.length}  
    16.   for (i = 0; i < x.length; i++) {  
    17.      x[i].style.display = "none";    
    18.   }  
    19.   x[slideIndex-1].style.display = "block";    
    20. }  
    21. </script> 

    There is the strangest thing.  When I use the code above and the CSS and HTML it works great outside of SharePoint.  The slider does not work automatically; you have to click on the left or right arrows to advance it manually, which is what I want.  But then when I take the same code and integrate it into a SharePoint page using a content editor and a script editor web parts, everything works except one thing...

     

     

    When you click the arrows on it,  it advances but then in 1 or 2 seconds, it bounces back to the first slide.  It's almost as if it suddenly has a mind of its own.  Outside of SharePoint and it does not do this at all.

    It also looks as if SharePoint is refreshing the page when you click the slider's arrows, causing it to bounce back.

     

     

    By looking at the JS can anyone see where I could tweak that code so it will not bounce back like it is - even though it does NOT bounce back when it's not in SP?  Weird, I know but am just hoping someone can help me.

    解决方案

    My guess is that n is getting set to x+1, and jumping back to slide 1. Figure out if n is getting changed somehow by SharePoint??


    这篇关于如何解决SP中断的Javascript问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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