javascript在firefox中未按预期工作

javascript在firefox中未按预期工作,javascript,firefox,Javascript,Firefox,我有一个简单的JavaScript,它可以在除Firefox(26)之外的所有主流浏览器中运行。我环顾四周,找不到它不能运行的原因 它的目的是改变元素的style.left,它将在Firefox中第一次工作,但不会超过一次。它可以在我尝试过的所有其他浏览器中正常工作。这是脚本的精简版本,以防任何人发现未使用的变量等 这里是一个不完整的JavaScript和html的副本 请求的工作JSFIDLE…jsfiddle.net/zvSMa/1 JavaScript: var left; functi

我有一个简单的JavaScript,它可以在除Firefox(26)之外的所有主流浏览器中运行。我环顾四周,找不到它不能运行的原因

它的目的是改变元素的style.left,它将在Firefox中第一次工作,但不会超过一次。它可以在我尝试过的所有其他浏览器中正常工作。这是脚本的精简版本,以防任何人发现未使用的变量等

这里是一个不完整的JavaScript和html的副本

请求的工作JSFIDLE…jsfiddle.net/zvSMa/1

JavaScript:

var left;

function scroll_left(direction){
 left = parseInt(document.getElementById("body").offsetLeft,10);


if (left == -2868) {
return;
 }else{
      switch(left){
           case -1:                  
                stop = -955;
                smooth_scroll(left,stop);
               left=-955;
                break;
           case 0:                  
                stop = -955;
                smooth_scroll(left,stop);

                break;
           case -955:
                stop = -1910;
                smooth_scroll(left,stop);
                break;
           case -1910:
                stop = -2865;
                smooth_scroll(left,stop);


                break;
           case -2865:               
                break;
           }
      }
}


function smooth_scroll(current,stop){
 document.getElementById("body").style.left= stop+"px";
 left = parseInt(document.getElementById("body").offsetLeft,10);
 document.getElementById("dummy").innerHTML = current;
 document.getElementById("dummy2").innerHTML = stop;


}

function scroll_right(direction){
 left = parseInt(document.getElementById("body").offsetLeft,10);


if (left == 2868) {
      return;
 }else{
      switch(left){
           case -1:                  

                break;
           case 0:                  


                break;
           case -955:
                stop = -0;
                smooth_scroll(left,stop);
                break;
           case -1910:
                stop = -955;
                smooth_scroll(left,stop);


                break;
           case -2865:
                stop = -1910;
                smooth_scroll(left,stop);

                break;
           }
      }
}
<!DOCTYPE HTML>   
<!--Advanced Design and Solutions-->
<html>
<head>
    <meta charset="utf-8">
    <title>
        Under Construction
    </title>
    <link rel="stylesheet" type="text/css" href="form.css">
    <meta name="author" content="Advanced Design And Solutions">
    <meta name="description" content="x">
    <meta name="keywords" content="x">
    <script type="text/javascript" src="script/script.js">
</script>

</head>
<body>
    <div id="container">
        <div id="banner">
            <a class="title_logo" href="index.php">
                Advanced Design and Solutions
            </a>
            <div id="links">
                <a class="banner_content" id="on" href="web%20design.php">Web Design</a><a class="banner_content" href="marketing%20material%20design.php">Marketing Material</a><a class="banner_content" href="logo%20design.php">Logo Design</a><a class="banner_content" href="business%20card%20design.php">Business Card Design</a>
            </div>

            <div id="email_panel">
                <form class="" action="MAILTO:contact@advanceddesignandsolutions.com" method="post" enctype="text/plain">
                    <fieldset class="contact">
                        <legend><span class="page_text text_spacing">Send us an Email at contact@AdvancedDesignandSolutions.com</span></legend>
                        <p class="page_text text_spacing">
                            Please fill out this short form and we will get back to you as soon as possible with a reply.
                        </p>

                            <input type="radio" name="product" value="Web Design">Web Design <input type="radio" name="product" value="Marketing Materials">Marketing Materials <input type="radio" name="product" value="Logos">Logos <input type="radio" name="product" value="Business Cards">Business Cards <input type="radio" name="product" value="Other">Other
                        <br>
                        <label class="page_text">Name: <input class="alignment" type="text" name="client" required="required" placeholder="FIRST AND LAST NAME"></label> <!--label with input-->
                        <br>
                        <br>
                        <label class="page_text">Email: <input class="alignment" type="email" name="email" required="required" placeholder="ADDRESS@EXAMPLE.COM"></label><br>
                        <br>
                        <label class="page_text">Tel: <input class="alignment" id="phoneinput" type="tel" required="required" name="Phone"></label><br>
                        <label class="page_text">Inquiry: 
                        <textarea class="" type="text" name="" required="required">
</textarea></label><br>
                            <br>
                            <br>
                            <input class="button" type="submit" value="Submit"> <input class="button" type="reset" value="Reset">
                        </fieldset>
                    </form>
                </div>
            </div>


            <div id="hider">
                <div id="l_arrow" onclick="scroll_left(-2);">
                    &laquo;
                </div>
                <div id="r_arrow" onclick="scroll_right(2);">
                    &raquo;
                </div>
                <div id="body">
                    <div id="content_pane_1">
                        <h2>
                            Web Design
                        </h2>
                        <p>
                            A website is an important marketing and informational tool for you and your business. Your website can be used for various purposes, to define your company's brand, to advertise promotional sales or discounts, to give an insight or introduction into your company. No matter what purpose you have in mind for your site, we would be glad to take the website journey with you!
                        </p>
                    </div>
                    <div id="content_pane_2">
                        <h2>
                            Marketing Materials
                        </h2>
                        <p>
                            We design marketing materials in any shape and size, such as promotional pamphlets, tri-fold brochures, door hangers, as well as anything else you can think up. We enjoy helping your business come up with creative, clever and professional marketing materials. We also provide competitively priced printing services for your designs.
                        </p>
                    </div>
                    <div id="content_pane_3">
                        <h2>
                            Logo Design
                        </h2>
                        <p>
                            A logo is an integral part of your company's brand or image. It serves to identify your company's product or service. Proper branding can result in higher sales for the products you sell because of brand loyalty. A well thought out branding with a quality logo can allow you to shape how your company is viewed i.e., youthfulness, fun or luxury. If you are looking to create an image for your company or re-branding your existing business, we look forward to putting our creativity to work for you!
                        </p>
                    </div>
                    <div id="content_pane_4">
                        <h2>
                            Business Card Design
                        </h2>
                        <p>
                            A business card is often part of the first contact that you will have with your potential client or customer. So it is invaluable that you make a good first impression. A quality designed and printed business card will help you establish your the image of quality and professionalism. When it come time to design you business card or reprint your existing design, we wont be beat on quality or service!
                        </p>
                    </div>
                </div>
                <div id="dummy"></div><div id="dummy2"></div>
            </div>          <div id="footer">
            <div id="footer_topline"></div>
            <a class="footer_links" href="index.php">Home</a><a class="footer_links" href="web%20design.php">Web Design</a><a class="footer_links" href="marketing%20material%20design.php">Marketing Material Design</a><a class="footer_links" href="logo%20design.php">Logo Design</a><a class="footer_links" href="business%20card%20design.php">Business Card Design</a><a class="footer_links" href="index.php">&#169; Copyright  <?php echo date("Y") ?></a>


        </div>
    </div>
</body>
</html>
html:

var left;

function scroll_left(direction){
 left = parseInt(document.getElementById("body").offsetLeft,10);


if (left == -2868) {
return;
 }else{
      switch(left){
           case -1:                  
                stop = -955;
                smooth_scroll(left,stop);
               left=-955;
                break;
           case 0:                  
                stop = -955;
                smooth_scroll(left,stop);

                break;
           case -955:
                stop = -1910;
                smooth_scroll(left,stop);
                break;
           case -1910:
                stop = -2865;
                smooth_scroll(left,stop);


                break;
           case -2865:               
                break;
           }
      }
}


function smooth_scroll(current,stop){
 document.getElementById("body").style.left= stop+"px";
 left = parseInt(document.getElementById("body").offsetLeft,10);
 document.getElementById("dummy").innerHTML = current;
 document.getElementById("dummy2").innerHTML = stop;


}

function scroll_right(direction){
 left = parseInt(document.getElementById("body").offsetLeft,10);


if (left == 2868) {
      return;
 }else{
      switch(left){
           case -1:                  

                break;
           case 0:                  


                break;
           case -955:
                stop = -0;
                smooth_scroll(left,stop);
                break;
           case -1910:
                stop = -955;
                smooth_scroll(left,stop);


                break;
           case -2865:
                stop = -1910;
                smooth_scroll(left,stop);

                break;
           }
      }
}
<!DOCTYPE HTML>   
<!--Advanced Design and Solutions-->
<html>
<head>
    <meta charset="utf-8">
    <title>
        Under Construction
    </title>
    <link rel="stylesheet" type="text/css" href="form.css">
    <meta name="author" content="Advanced Design And Solutions">
    <meta name="description" content="x">
    <meta name="keywords" content="x">
    <script type="text/javascript" src="script/script.js">
</script>

</head>
<body>
    <div id="container">
        <div id="banner">
            <a class="title_logo" href="index.php">
                Advanced Design and Solutions
            </a>
            <div id="links">
                <a class="banner_content" id="on" href="web%20design.php">Web Design</a><a class="banner_content" href="marketing%20material%20design.php">Marketing Material</a><a class="banner_content" href="logo%20design.php">Logo Design</a><a class="banner_content" href="business%20card%20design.php">Business Card Design</a>
            </div>

            <div id="email_panel">
                <form class="" action="MAILTO:contact@advanceddesignandsolutions.com" method="post" enctype="text/plain">
                    <fieldset class="contact">
                        <legend><span class="page_text text_spacing">Send us an Email at contact@AdvancedDesignandSolutions.com</span></legend>
                        <p class="page_text text_spacing">
                            Please fill out this short form and we will get back to you as soon as possible with a reply.
                        </p>

                            <input type="radio" name="product" value="Web Design">Web Design <input type="radio" name="product" value="Marketing Materials">Marketing Materials <input type="radio" name="product" value="Logos">Logos <input type="radio" name="product" value="Business Cards">Business Cards <input type="radio" name="product" value="Other">Other
                        <br>
                        <label class="page_text">Name: <input class="alignment" type="text" name="client" required="required" placeholder="FIRST AND LAST NAME"></label> <!--label with input-->
                        <br>
                        <br>
                        <label class="page_text">Email: <input class="alignment" type="email" name="email" required="required" placeholder="ADDRESS@EXAMPLE.COM"></label><br>
                        <br>
                        <label class="page_text">Tel: <input class="alignment" id="phoneinput" type="tel" required="required" name="Phone"></label><br>
                        <label class="page_text">Inquiry: 
                        <textarea class="" type="text" name="" required="required">
</textarea></label><br>
                            <br>
                            <br>
                            <input class="button" type="submit" value="Submit"> <input class="button" type="reset" value="Reset">
                        </fieldset>
                    </form>
                </div>
            </div>


            <div id="hider">
                <div id="l_arrow" onclick="scroll_left(-2);">
                    &laquo;
                </div>
                <div id="r_arrow" onclick="scroll_right(2);">
                    &raquo;
                </div>
                <div id="body">
                    <div id="content_pane_1">
                        <h2>
                            Web Design
                        </h2>
                        <p>
                            A website is an important marketing and informational tool for you and your business. Your website can be used for various purposes, to define your company's brand, to advertise promotional sales or discounts, to give an insight or introduction into your company. No matter what purpose you have in mind for your site, we would be glad to take the website journey with you!
                        </p>
                    </div>
                    <div id="content_pane_2">
                        <h2>
                            Marketing Materials
                        </h2>
                        <p>
                            We design marketing materials in any shape and size, such as promotional pamphlets, tri-fold brochures, door hangers, as well as anything else you can think up. We enjoy helping your business come up with creative, clever and professional marketing materials. We also provide competitively priced printing services for your designs.
                        </p>
                    </div>
                    <div id="content_pane_3">
                        <h2>
                            Logo Design
                        </h2>
                        <p>
                            A logo is an integral part of your company's brand or image. It serves to identify your company's product or service. Proper branding can result in higher sales for the products you sell because of brand loyalty. A well thought out branding with a quality logo can allow you to shape how your company is viewed i.e., youthfulness, fun or luxury. If you are looking to create an image for your company or re-branding your existing business, we look forward to putting our creativity to work for you!
                        </p>
                    </div>
                    <div id="content_pane_4">
                        <h2>
                            Business Card Design
                        </h2>
                        <p>
                            A business card is often part of the first contact that you will have with your potential client or customer. So it is invaluable that you make a good first impression. A quality designed and printed business card will help you establish your the image of quality and professionalism. When it come time to design you business card or reprint your existing design, we wont be beat on quality or service!
                        </p>
                    </div>
                </div>
                <div id="dummy"></div><div id="dummy2"></div>
            </div>          <div id="footer">
            <div id="footer_topline"></div>
            <a class="footer_links" href="index.php">Home</a><a class="footer_links" href="web%20design.php">Web Design</a><a class="footer_links" href="marketing%20material%20design.php">Marketing Material Design</a><a class="footer_links" href="logo%20design.php">Logo Design</a><a class="footer_links" href="business%20card%20design.php">Business Card Design</a><a class="footer_links" href="index.php">&#169; Copyright  <?php echo date("Y") ?></a>


        </div>
    </div>
</body>
</html>

在建工程
发送电子邮件至contact@AdvancedDesignandSolutions.com

请填写这张简短的表格,我们会尽快回复您。

网页设计营销材料徽标名片其他
姓名:

电子邮件:

电话:
查询:


&拉阔; &拉阔; 网页设计 网站对于你和你的企业来说是一个重要的营销和信息工具。您的网站可以用于各种目的,定义您公司的品牌,宣传促销或折扣,深入了解或介绍您的公司。无论您对您的网站有什么目的,我们都很乐意与您一起踏上网站之旅!

营销材料 我们设计任何形状和大小的营销材料,如宣传小册子、三折小册子、门挂,以及任何你能想到的东西。我们乐于帮助您的企业提供创意、智能和专业的营销材料。我们还为您的设计提供具有竞争力的价格印刷服务。

标志设计 徽标是公司品牌或形象的组成部分。它用于识别您公司的产品或服务。由于品牌忠诚度,适当的品牌推广可以提高您所销售产品的销售额。一个经过深思熟虑的品牌和一个优质的标志可以让你塑造你的公司是如何看待的,即年轻,有趣或豪华。如果您希望为您的公司树立形象或重塑现有业务的品牌,我们期待着将我们的创意用于您的工作!

名片设计 名片通常是你与潜在客户的第一次接触的一部分。因此,给人留下良好的第一印象是非常宝贵的。一张高质量设计和印刷的名片将帮助您树立高质量和专业的形象。当您需要设计名片或重印现有设计时,我们不会在质量或服务上被击败!


通过深入研究firefox对javascript的响应,我发现它的响应方式不同。所有其他浏览器都将更改样式。left以匹配我指定的样式。firefox从-1开始表示offsetleft,而其他浏览器从0开始表示所有切换情况错误。

您会遇到什么错误?无。如果我遇到错误,它会给我一个开始的位置。它在FireFox中没有做什么,它应该做什么?单击它应该更改样式。左。它将在firefox中这样做,但只有一次。它应该在随后的点击中完成,而使用JSFIDLE将大大有助于其他人更容易地进行调试。