简体   繁体   English

为什么这个html代码给我一个错误?

[英]Why does this html code give me an error?

This the index.cshtml file 这个index.cshtml文件

@{
        ViewBag.Title = "Vishwaprani Healing Centre";
    }

    <body>
        <div id="wowslider-container1">
            <div class="ws_images">
                <ul>
                    <li><img src="@Url.Content("~/images/slider6.jpg")" alt="slider6" title="slider6" id="wows1_0" /></li>
                    <li><img src="@Url.Content("~/images/slider1.jpg")" alt="slider1" title="slider1" id="wows1_1" /></li>
                    <li><img src="@Url.Content("~/images/slider2.jpg")" alt="slider2" title="slider2" id="wows1_2" /></li>
                    <li><img src="@Url.Content("~/images/slider3.jpg")" alt="slider3" title="slider3" id="wows1_3" /></li>
                    <li><img src="@Url.Content("~/images/slider4.jpg")" alt="slider4" title="slider4" id="wows1_4" /></li>
                    <li><img src="@Url.Content("~/images/slider5.jpg")" alt="slider5" title="slider5" id="wows1_5" /></li>
                    <li><img src="@Url.Content("~/images/slider7.jpg")" alt="slider7" title="slider7" id="wows1_6" /></li>
                    <li><img src="@Url.Content("~/images/slider8.jpg")" alt="slider8" title="slider8" id="wows1_7" /></li>
                    <li><img src="@Url.Content("~/images/slider9.jpg")" alt="jquery photo gallery" title="slider9" id="wows1_8" /></li>
                    <li><img src="@Url.Content("~/images/slider10.jpg")" alt="slider10" title="slider10" id="wows1_9" /></li>
                </ul>
            </div>
            <div class="ws_bullets">
                <div>
                    <a href="#" title="slider6"><span><img src="@Url.Content("~/images/thumb6.jpg")" alt="slider6" />1</span></a>
                    <a href="#" title="slider1"><span><img src="@Url.Content("~/images/thumb1.jpg")" alt="slider1" />2</span></a>
                    <a href="#" title="slider2"><span><img src="@Url.Content("~/images/thumb2.jpg")" alt="slider2" />3</span></a>
                    <a href="#" title="slider3"><span><img src="@Url.Content("~/images/thumb3.jpg")" alt="slider3" />4</span></a>
                    <a href="#" title="slider4"><span><img src="@Url.Content("~/images/thumb4.jpg")" alt="slider4" />5</span></a>
                    <a href="#" title="slider5"><span><img src="@Url.Content("~/images/thumb5.jpg")" alt="slider5" />6</span></a>
                    <a href="#" title="slider7"><span><img src="@Url.Content("~/images/thumb7.jpg")" alt="slider7" />7</span></a>
                    <a href="#" title="slider8"><span><img src="@Url.Content("~/images/thumb8.jpg")" alt="slider8" />8</span></a>
                    <a href="#" title="slider9"><span><img src="@Url.Content("~/images/thumb9.jpg")" alt="slider9" />9</span></a>
                    <a href="#" title="slider10"><span><img src="@Url.Content("~/images/thumb10.jpg")" alt="slider10" />10</span></a>
                </div>
            </div><div class="ws_script" style="position:absolute;left:-99%"><a href="http://wowslider.com">javascript slideshow</a> by WOWSlider.com v8.2</div>
            <div class="ws_shadow"></div>
        </div>
        <script type="text/javascript" src="~/Scripts/script.js"></script>
        <script type="text/javascript" src="~/Scripts/wowslider.js"></script>        
    </body>

This is the _Layout.cshtml code==> 这是_Layout.cshtml代码==>

https://docs.google.com/document/d/1qjQneUBALpjcxghWYEdKnBdnftmBybNA2W5lYqI7y9Q/edit https://docs.google.com/document/d/1qjQneUBALpjcxghWYEdKnBdnftmBybNA2W5lYqI7y9Q/edit

The problem is when I execute above Index.cshtml which contains a web slider with the given _Layout.cshtml in Visual Studio 2013 it gives me an error like this.==> 问题是,当我执行上述Index.cshtml其中包含Visual Studio 2013它给了我这样的错误网页滑块与给定_Layout.cshtml。==> 在此处输入图片说明 This that function mentioned in that image which causes the error.==> 该图像中提到的该函数会导致错误。==>

$("#wowslider-container1").wowSlider({ effect: "tv,glass_parallax,parallax,brick,collage,seven,kenburns,cube,blur,book,rotate,domino,slices,blast,blinds,basic,basic_linear,fade,fly,flip,page,stack,stack_vertical", prev: "", next: "", duration: 20 * 100, delay: 20 * 100, width: 1024, height: 768, autoPlay: true, autoPlayVideo: false, playPause: true, stopOnHover: false, loop: false, bullets: 1, caption: true, captionEffect: "parallax", controls: true, controlsThumb: false, responsive: 2, fullScreen: false, gestures: 2, onBeforeStep: 0, images: 0 });

This is that .wowSlider method that should be linked to above code==> 这是应该链接到上述代码的.wowSlider方法==>

https://docs.google.com/document/d/1ZsZp3XEiAKUdMaE5qbcA6idFW6vU66ivdT1wYLQZ_qY/edit https://docs.google.com/document/d/1ZsZp3XEiAKUdMaE5qbcA6idFW6vU66ivdT1wYLQZ_qY/edit

But when the slider is executed in normal html file it will execute without a problem. 但是,当在普通的html文件中执行滑块时,它将毫无问题地执行。 ==> ==>

在此处输入图片说明

Is there any modification that needs to be done when the code is executed in an IIS express server? 在IIS Express服务器中执行代码时是否需要进行任何修改?

So, The problem as it is usual (order of scripts). 因此,通常的问题(脚本的顺序)。

As in the question the function for wowslider is called before it had a definition in the DOM. 就像在问题中一样, wowslider的函数在它在DOM中定义之前就被调用了。

It needs to be invoked after the library has been loaded. 库加载后需要调用它。

Problem- 问题-

<script type="text/javascript" src="~/Scripts/script.js"></script> //function called before the library loads.
<script type="text/javascript" src="~/Scripts/wowslider.js"></script> //library loaded after

Solution- 解-

 <script type="text/javascript" src="~/Scripts/wowslider.js"></script> //library is loaded first
 <script type="text/javascript" src="~/Scripts/script.js"></script>

it's a matter of including the right scripts. 包括正确的脚本是一个问题。 If you did, check the paths. 如果这样做,请检查路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM