IE 和 Chrome(开发工具)都没有显示任何错误,然后呢?

发布于 2024-11-16 21:07:18 字数 4892 浏览 0 评论 0原文

$(".slides_container").append(liHtml) 语法正确吗?没有人(浏览器客户端)在抱怨。

<link rel="stylesheet" href="_layouts/jquery/global.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="_layouts/jquery/slides.min.jquery.js"></script>


<script>
        $(function(){
            $('#slides').slides({
                preload: true,
                preloadImage: '_layouts/jquery/loading.gif',
                play: 5000,
                pause: 2500,
                hoverPause: true,
                animationStart: function(current){
                    $('.caption').animate({
                        bottom:-50
                    },100);
                    if (window.console && console.log) {
                        // example return of current slide number
                        console.log('animationStart on slide: ', current);
                    };
                },
                animationComplete: function(current){
                    $('.caption').animate({
                        bottom:0
                    },200);
                    if (window.console && console.log) {
                        // example return of current slide number
                        console.log('animationComplete on slide: ', current);
                    };
                },
                slidesLoaded: function() {
                    $('.caption').animate({
                        bottom:0
                    },200);
                }
            });
        });
</script>

<div id="container">    
    <div id="slides">
        <div class="slides_container"></div>
        <a href="#" class="prev"><img src="_layouts/jquery/arrow-prev.png" width="24" height="43" alt="Arrow Prev"></a>
        <a href="#" class="next"><img src="_layouts/jquery/arrow-next.png" width="24" height="43" alt="Arrow Next"></a>
    </div>
    <img src="_layouts/jquery/example-frame.png" width="739" height="341" alt="Example Frame" id="frame">
</div>      

<script>

  function GetAllImages()
    {
       $("#slideshowPicturePlaceholder").css("display", "block");
       var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
       soapEnv += "<listName>Splash Image Rotator</listName>";
       soapEnv += "<query><Query><Where><Eq> <FieldRef Name='Active'/> <Value Type='Boolean'>1</Value> </Eq> </Where><OrderBy Override='TRUE'><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query></query>";
       soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='ows_FileLeafRef'/><FieldRef Name='NewsLink'/></ViewFields></viewFields><rowLimit></rowLimit>";      
       soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";

       var port = window.location.port;
       if (port.length <= 0)
       port = "";
       else
       port = ":" + port;
       var webservice = window.location.protocol + "//" + window.location.hostname + port + L_Menu_BaseUrl + "/_vti_bin/lists.asmx";

       $.ajax(
       {
          url : webservice,
          type : "POST",
          dataType : "xml",
          data : soapEnv,
          complete : processQueryResults,
          contentType : "text/xml; charset=utf-8",
          error : function (xhr)
          {
             alert('Error!  Status = ' + xhr.status);
          }
       });   
    }
    function processQueryResults(xData, status)
    {
       var port = window.location.port;
       if (port.length <= 0)
       port = "";
       else
       port = ":" + port;

       var imageURL = window.location.protocol + "//" + window.location.hostname + port + L_Menu_BaseUrl + "/Splash Image Rotator/";           
       $(xData.responseXML).find("z\\:row").each(function ()
       {
          var title = $(this).attr("ows_Title");          
          var imageLink = imageURL + $(this).attr("ows_FileLeafRef").substring($(this).attr("ows_FileLeafRef").indexOf('#') + 1);         
          var itemLink = $(this).attr("ows_NewsLink");
          var liHtml = "<div class='slide'><a href='"+itemLink+"' target='_blank' border='0'><img width='420' height='220'  src='" + imageLink +"'/></a>" + "<div class='caption' style=\"bottom:'0'\"><p>" + title + "</p></div></div>";

        $(".slides_container").append(liHtml);      
        });

    }             
GetAllImages();

</script>

Is the $(".slides_container").append(liHtml) correctly syntaxed? No 1 (browser client) is complaining.

<link rel="stylesheet" href="_layouts/jquery/global.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="_layouts/jquery/slides.min.jquery.js"></script>


<script>
        $(function(){
            $('#slides').slides({
                preload: true,
                preloadImage: '_layouts/jquery/loading.gif',
                play: 5000,
                pause: 2500,
                hoverPause: true,
                animationStart: function(current){
                    $('.caption').animate({
                        bottom:-50
                    },100);
                    if (window.console && console.log) {
                        // example return of current slide number
                        console.log('animationStart on slide: ', current);
                    };
                },
                animationComplete: function(current){
                    $('.caption').animate({
                        bottom:0
                    },200);
                    if (window.console && console.log) {
                        // example return of current slide number
                        console.log('animationComplete on slide: ', current);
                    };
                },
                slidesLoaded: function() {
                    $('.caption').animate({
                        bottom:0
                    },200);
                }
            });
        });
</script>

<div id="container">    
    <div id="slides">
        <div class="slides_container"></div>
        <a href="#" class="prev"><img src="_layouts/jquery/arrow-prev.png" width="24" height="43" alt="Arrow Prev"></a>
        <a href="#" class="next"><img src="_layouts/jquery/arrow-next.png" width="24" height="43" alt="Arrow Next"></a>
    </div>
    <img src="_layouts/jquery/example-frame.png" width="739" height="341" alt="Example Frame" id="frame">
</div>      

<script>

  function GetAllImages()
    {
       $("#slideshowPicturePlaceholder").css("display", "block");
       var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";
       soapEnv += "<listName>Splash Image Rotator</listName>";
       soapEnv += "<query><Query><Where><Eq> <FieldRef Name='Active'/> <Value Type='Boolean'>1</Value> </Eq> </Where><OrderBy Override='TRUE'><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query></query>";
       soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='ows_FileLeafRef'/><FieldRef Name='NewsLink'/></ViewFields></viewFields><rowLimit></rowLimit>";      
       soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";

       var port = window.location.port;
       if (port.length <= 0)
       port = "";
       else
       port = ":" + port;
       var webservice = window.location.protocol + "//" + window.location.hostname + port + L_Menu_BaseUrl + "/_vti_bin/lists.asmx";

       $.ajax(
       {
          url : webservice,
          type : "POST",
          dataType : "xml",
          data : soapEnv,
          complete : processQueryResults,
          contentType : "text/xml; charset=utf-8",
          error : function (xhr)
          {
             alert('Error!  Status = ' + xhr.status);
          }
       });   
    }
    function processQueryResults(xData, status)
    {
       var port = window.location.port;
       if (port.length <= 0)
       port = "";
       else
       port = ":" + port;

       var imageURL = window.location.protocol + "//" + window.location.hostname + port + L_Menu_BaseUrl + "/Splash Image Rotator/";           
       $(xData.responseXML).find("z\\:row").each(function ()
       {
          var title = $(this).attr("ows_Title");          
          var imageLink = imageURL + $(this).attr("ows_FileLeafRef").substring($(this).attr("ows_FileLeafRef").indexOf('#') + 1);         
          var itemLink = $(this).attr("ows_NewsLink");
          var liHtml = "<div class='slide'><a href='"+itemLink+"' target='_blank' border='0'><img width='420' height='220'  src='" + imageLink +"'/></a>" + "<div class='caption' style=\"bottom:'0'\"><p>" + title + "</p></div></div>";

        $(".slides_container").append(liHtml);      
        });

    }             
GetAllImages();

</script>

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

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

发布评论

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

评论(1

风情万种。 2024-11-23 21:07:18

我使用 W3C 验证器 根据 HTML5 文档类型检查您的标记(经过一些编辑):

<!DOCTYPE html>
<html>
  <head>
     <title>asdf</title>
  </head>
  <body>
    <div class='slide'><a href='asdf' target='_blank' border='0'><img width='420' height='220'  src='asdf'/></a><div class='caption' style='bottom:0'><p>asdf</p></div></div>
  </body>
</html>

这会出现以下错误:

  • 锚点没有边框属性。您的意思是将其样式设置为 吗?
  • 图像应该有一个 alt 标签

所以是的,您在 liHtml 的标记无效,但很容易修复。

I used the W3C validator to check your markup (a bit edited) against the HTML5 doctype:

<!DOCTYPE html>
<html>
  <head>
     <title>asdf</title>
  </head>
  <body>
    <div class='slide'><a href='asdf' target='_blank' border='0'><img width='420' height='220'  src='asdf'/></a><div class='caption' style='bottom:0'><p>asdf</p></div></div>
  </body>
</html>

This gives the following errors:

  • an anchor does not have a border attribute. Did you mean to style it like <a style="border:0;">?
  • an image should have an alt tag

So yes, your markup at liHtml is invalid, but easy to fix.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文