то, как зафиксировать document.body, является пустой ошибкой

Для чего-то немного различного Вы могли использовать JRuby и Мокко , которые объединены в JtestR к тестам записи на Ваш код Java в выразительном и сжатом Ruby. Существуют некоторые полезные примеры насмешки с JtestR здесь . Одно преимущество этого подхода состоит в том, что насмешка реальных классов очень проста.

11
задан zaius 29 March 2014 в 23:36
поделиться

4 ответа

I agree with outis - we need some more code.

That said:

  • Are you sure you're doing all your work inside the $(document).ready function?
  • Do you definitely have a correctly formed (and closed) body tag and valid xhtml?
  • Does this happen on all browsers?

One suggestion:

Does the problem persist if you put the positioneerElement function in the $(document).ready function as well? I'm wondering whether the browser evaluates document.body prior to the document loading.

$(document).ready(function() {
    function positioneerElement(){      
    $breedte = (document.body.clientWidth - 1124) / 2;
    $('#bg_left').css({
        'width': $breedte
    });
    $('.container').css({
        'margin-left': $breedte
    });

    // your other code, including
    positioneerElement();
});
8
ответ дан 3 December 2019 в 07:13
поделиться

Make sure you only call $(window).width() after you have included the tag (eg. in the ready callback), and/or use a Standards Mode doctype declaration. You should be doing that anyway: Quirks Mode sucks.

The issue is, to read the viewport size in Quirks Mode jQuery must look at document.body.clientWidth instead of document.documentElement.clientWidth. If you haven't started your yet, there is not document.body node present.

6
ответ дан 3 December 2019 в 07:13
поделиться

Ну, исходя из информации, которую вы мне дали, возможно, тело еще не загрузилось должным образом. Дополнительные сведения см. Здесь: http://www.coderanch.com/t/122834/HTML-JavaScript/document-body-null-or-not#606782

Я бы сказал больше, но я тоже согласен с outis, что вам нужно опубликовать еще код для отладки.

1
ответ дан 3 December 2019 в 07:13
поделиться

Вы должны включить jquery.js, а не jquery.min.js Похоже в нем какой-то баг У меня работает

2
ответ дан 3 December 2019 в 07:13
поделиться
Другие вопросы по тегам:

Похожие вопросы: