Jquery vs IE 在黑暗的小巷 - 第 1 轮(上滑和下滑)

发布于 2024-09-30 20:31:54 字数 2355 浏览 7 评论 0原文

我感觉我正在服用疯狂的药片。我快要失去理智解决手头的问题了,但最终 IE7 并没有像它应该的那样使用 jquery 'slideDown' 和 'slideup' 函数。

所有其他浏览器都可以工作。我最初的理论是 .focus 的问题(因为 ie 无法识别)。当我将功能切换到 .click 时,它仍然不起作用。

今晚请救我一命。

<script type="text/javascript">
$(function()
{
    $("#message").click(function() {
        $(this).animate({"height": "85px",}, "fast" );
        $("#button_block").slideDown("fast");
        return false;
    });

    $("#cancel").click(function() {
        $("#message").animate({"height": "30px",}, "fast" );
        $("#button_block").slideUp("fast");
    return false;
    });

    $("#submit").click(function() {
        $("#message").animate({"height": "30px",}, "fast" );
        $("#button_block").slideUp("fast");
    return false;
    }); 

});

</script>

另外请求 HTML 片段

<div id="shout"></div>


<form method="post" action="shout.php">
   <textarea id="message" name="message" class="message" value="enter text here"></textarea>
                <div id="button_block" style="padding:0 0 15px;">
                    <input type="submit" id="submit" value="Submit"/>
                    <input type="submit" id="cancel" value="Cancel" />
                </div>
</form>

,在此文件上方创建的“shoutbox”在 ie7 中也不起作用(尽管在任何其他浏览器中都可以正常工作)。它的代码是:

<script type="text/javascript">
$(function() {

    refresh_shoutbox();
    setInterval("refresh_shoutbox()", 15000);

    $("#submit").click(function() {
        var name    = $("#name").val();
        var message = $("#message").val();
        var data            = 'name='+ name +'&message='+ message;

        $.ajax({
            type: "POST",
            url: "shout.php",
            data: data,
            success: function(html){
                $("#shout").slideToggle(500, function(){
                    $(this).html(html).slideToggle(500);
                    $("#shout").val("");
                });
          }
        });    
        return false;
    });
});

function refresh_shoutbox() {
    var data = 'refresh=1';

    $.ajax({
            type: "POST",
            url: "shout.php",
            data: data,
            success: function(html){
                $("#shout").html(html);
            }
        });
}

</script>

I feel like I'm taking crazy pills. About to lose my mind solving the issue at hand but ultimately IE7 does not use jquery 'slideDown' and 'slideup' function as it should.

All other browsers work. My initial theory is the issue lying with the .focus (since ie does not recognize). When i switch the function to .click, it still does not function however.

Please save my life tonight.

<script type="text/javascript">
$(function()
{
    $("#message").click(function() {
        $(this).animate({"height": "85px",}, "fast" );
        $("#button_block").slideDown("fast");
        return false;
    });

    $("#cancel").click(function() {
        $("#message").animate({"height": "30px",}, "fast" );
        $("#button_block").slideUp("fast");
    return false;
    });

    $("#submit").click(function() {
        $("#message").animate({"height": "30px",}, "fast" );
        $("#button_block").slideUp("fast");
    return false;
    }); 

});

</script>

HTML snippet requested

<div id="shout"></div>


<form method="post" action="shout.php">
   <textarea id="message" name="message" class="message" value="enter text here"></textarea>
                <div id="button_block" style="padding:0 0 15px;">
                    <input type="submit" id="submit" value="Submit"/>
                    <input type="submit" id="cancel" value="Cancel" />
                </div>
</form>

additionally, the 'shoutbox' created above this file does not work in ie7 either (although works just fine in any other browser). Code for it is:

<script type="text/javascript">
$(function() {

    refresh_shoutbox();
    setInterval("refresh_shoutbox()", 15000);

    $("#submit").click(function() {
        var name    = $("#name").val();
        var message = $("#message").val();
        var data            = 'name='+ name +'&message='+ message;

        $.ajax({
            type: "POST",
            url: "shout.php",
            data: data,
            success: function(html){
                $("#shout").slideToggle(500, function(){
                    $(this).html(html).slideToggle(500);
                    $("#shout").val("");
                });
          }
        });    
        return false;
    });
});

function refresh_shoutbox() {
    var data = 'refresh=1';

    $.ajax({
            type: "POST",
            url: "shout.php",
            data: data,
            success: function(html){
                $("#shout").html(html);
            }
        });
}

</script>

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

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

发布评论

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

评论(2

初心未许 2024-10-07 20:31:54

我似乎记得 IE7 在键值对上有尾随逗号的问题。我会尝试删除多余的逗号,看看是否有帮助。

从:

$(this).animate({"height": "85px",}, "fast" );

到:

$(this).animate({"height": "85px"}, "fast" );

I seem to remember IE7 having issues with trailing commas on key value pairs. I would try removing the extra commas as see if it helps.

from:

$(this).animate({"height": "85px",}, "fast" );

to:

$(this).animate({"height": "85px"}, "fast" );
空宴 2024-10-07 20:31:54

您是否尝试过将 SlideUp/slideDown 作为 animate 方法的回调运行?

例如:

$("#message").click(function() {
        $(this).animate({"height": "85px",}, "fast", function() {
          $("#button_block").slideDown("fast");
        });        
        return false;
});

IE 可能会遇到问题,因为当调用 SlideDown/Up 时,高度没有被占用。

Have you tried running the slideUp/slideDown as a callback from the animate method?

For example:

$("#message").click(function() {
        $(this).animate({"height": "85px",}, "fast", function() {
          $("#button_block").slideDown("fast");
        });        
        return false;
});

It's possible IE is having trouble because the height is not being taken up when the slideDown/Up is called.

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