Проблема с методом jQuery .load и новыми строками в Internet Explorer. - PullRequest
2 голосов
/ 14 декабря 2010

Я пытаюсь загрузить данные в незашифрованном виде, используя метод загрузки jQuery.Этот открытый текст включает разрывы строк.Я загружаю эти данные в HTML

tag.</p>

<p>It works fine in all browsers I tried (Firefox/Linux, [Firefox,Chrome,Opera]/Windows) except for Internet Explorer, where the line breaks from the original file are removed. I've tried to save the file with either Windows line-breaks and Linux line-breaks, but this makes no difference with respect to browser behavior (neither IE, which continues to misbehave, nor the others, which keep behaving).</p>

<p>This is the HTML code:</p>

<pre><code><div id="data">
    <pre>

Это вызов jQuery:

$(function(){
    $("#data pre").load("lorem.txt");
});

1 Ответ

4 голосов
/ 14 декабря 2010

... или вы можете заменить текст, если браузер IE:

$("#data pre").load("lorem.txt", function(response, status, xhr) {
    if (status != "error") {
    if (($.browser.msie)&&(jQuery.browser.version=="8.0"))
        $("#data pre").html(response.replace(/\r\n/g, "<br>"));
    }
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...