Question

I'm developing an AJAX site. So the problem is browsers (Safari, Chrome) do not show spaces in AJAX-loaded HTML content after tags like Strong, Em etc.

Then I added a doctype to the AJAX output. Everything was fine, there were all spaces, unless I tested the site in WebKit browsers. When I loaded the page in Safari, I got error:

This page contains the following errors:

error on line 1 at column 7: internal error

Below is a rendering of the page up to the first error.

What do I got to do? Or, in other words, is there any way to output the doctype for WebKit without getting the error?

Output is something like that:

<div class="topic">
    <div class="colon">
        <div class="topictext">
            <h2><a href="/artikul/1" class="showhuman" id="1" onclick="showhumaninfo (1); return false;">KirillTitov</a> tells us:</h2><p>Here you go.<br/>
<b>Bold text</b> <i>italic text</i> <strike>etc</strike>…</p> 
            </div><!-- topictext -->
            <div class="topicright"></div>
            <div class="clear"></div>
            <div class="topicinfo">
            <div class="topicclock">
                <font title="Timestamp for geeks — 1253816398">24&#0160;september,&#0160;year&#0160;2009</font>
            </div><!-- topicclock -->
            <div class="topiccomment">
                <a href="/joindachat/2" class="entertopic" id="2" onclick="entertopic (2); return false;">Go inside</a> (мнений: 0)
            </div><!-- topiccomment -->
        </div><!-- topicinfo -->
        <div class="topicindex">
            <img src="/img/bgtopicindex.gif" border="0" alt="" />
        </div><!-- topicindex -->
        <div class="blur"></div>
    </div><!-- colon -->
    <div class="colon">
        <div class="indextopcomment">
            <div class="commenttopleft"><img src="/img/bgcommentindexgreen.gif" alt="" border="0" /></div>
            <div class="texttopcomment nonenew">
                No comments here.
            </div>
            <div class="clear"></div>
            </div><!-- indextopcomment -->
            </div><!-- colon -->
            <div class="clear"></div>
        </div><!-- topic -->
    <div class="clear"></div>
</div><!-- topic -->
Was it helpful?

Solution

Have you thought about using &nbsp; in those places?

Also, try the following on your incoming ajax result:

.Replace("\xA0", "&nbsp;").Replace("\x20","&nbsp;");

Some frameworks behave odd in webkit and put not-standard spacing in, is what what you're seeing? Follow-up on if the replace works, if not there are other options, but that's usually the simplest/quickest fix. Here's a full table on the whitespace oddities, but it depends on browser/platform as to which quirk you're hitting normally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top