Forum Moderators: open
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n
aaaaaaaaaaaaaaaaaaaaaaa</td>
</tr>
</table>
Is it possible to avoid this?
I would like a carriage return although a string without any spaces...
Is it possible?
Any help appreciated.
Best regards.
Fabrizio
[edited by: BlobFisk at 9:29 am (utc) on June 12, 2004]
[edit reason] Removed scroll - \n is a manual line break. [/edit]
There are probably several solutions to this using CSS.
The most immediate one that I can think of is to use this in the html:<table><tr>
<td>a a a a a a a a a a a a a a a a a a a a a a a</td>
</tr></table>
I can't do this...there are some users that insert some text and If they insert a link so long? (they did!)
and this in the CSS:td {letter-spacing: 0.1em;}
Nope...it doesn't work.
It only renders the space between words but scroll bar still remains...
Any help?
Best regards.
Fabrizio
[quirksmode.org...]
The former works in Netscape 2-4 and IE 2-6.
The latter is W3C and works in Moz, Opera and Safari but doesn't work in IE (it actually prints some garbage)!
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
' #########################################################################
' WrapText
' Description: Used to wrap text
' Parameters:
' sText String The text that is to be wrapped
' Returns: String Text with <br /> inserted at wrap points
' #########################################################################
Function WrapText(sText, lMaxWidth)
Dim sReturn
Dim sRemainder
Dim lMark
sRemainder = sText
sReturn = ""
Do While Len(sRemainder) > lMaxWidth
lMark = InstrRev(sRemainder, " ", lMaxWidth)
If lMark = 0 Then
lMark = Instr(sRemainder, " ")
End If
If lMark > 0 Then
If sReturn <> "" Then
sReturn = sReturn & "<br />" & Left(sRemainder, lMark - 1)
Else
sReturn = Left(sRemainder, lMark - 1)
End If
If lMark < Len(sRemainder) Then
sRemainder = Mid(sRemainder, lMark + 1)
Else
sRemainder = ""
End If
Else
' no spaces left in string, so we're done
Exit Do
End If
Loop
If sReturn <> "" Then
WrapText = sReturn & "<br />" & sRemainder
Else
WrapText = sRemainder
End If
End FunctionFunction WrapTextWHangingIndent(sText, lMaxWidth, lIndentWidth)
Dim sReturn
Dim sRemainder
Dim lMark
Dim sIndent
Dim lLineWidth
Dim bIsFirstLine
Dim i
sRemainder = sText
sReturn = ""
lLineWidth = lMaxWidth
bIsFirstLine = True
sIndent = ""
Do While Len(sRemainder) > lLineWidth
lMark = InstrRev(sRemainder, " ", lLineWidth)
If bIsFirstLine Then
lLineWidth = lMaxWidth - lIndentWidth
For i = 0 To (lIndentWidth - 1)
sIndent = sIndent & " "
Next
bIsFirstLine = False
End If
If lMark = 0 Then
lMark = Instr(sRemainder, " ")
End If
If lMark > 0 Then
If sReturn <> "" Then
sReturn = sReturn & "<br />" & sIndent & Left(sRemainder, lMark - 1)
Else
sReturn = Left(sRemainder, lMark - 1)
End If
If lMark < Len(sRemainder) Then
sRemainder = Mid(sRemainder, lMark + 1)
Else
sRemainder = ""
End If
Else
' no spaces left in string, so we're done
Exit Do
End If
Loop
If sReturn <> "" Then
WrapTextWHangingIndent = sReturn & "<br />" & sIndent & sRemainder
Else
WrapTextWHangingIndent = sRemainder
End If
End Function
</SCRIPT>
however the first one i tried doesn't work, I create my own it is little more compact:
<%@ Language=VBScript %>
<%Function WrapText(sText, lMaxWidth)
sOriginal = sText
iPointer = 0
for idx = 1 to len(sText)
if idx = 1 then
sText = mid(sText, 1, lMaxWidth) & " <br /> "
iPointer = iPointer + 1
elseif idx mod lMaxWidth = 0 then
sText = sText & mid(sOriginal, (lMaxWidth*iPointer)+1, lMaxWidth) & " <br /> "
iPointer = iPointer + 1
end if
next
WrapText = sText
End Function
Response.Write(WrapText("abcdefghilmnopqrstuvzabcdefghilmn [red]\n[/red]
opqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvza[red]\n[/red]
bcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmn[red]\n[/red]
opqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvz[red]\n[/red]
abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghi[red]\n[/red]
lmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrst[red]\n[/red]
uvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdef[red]\n[/red]
ghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvz", 5))
Response.Write(WrapText("", 5))
%>
Regards.
Fabrizio
P.s. Sorry for the indentation, I'm not able to insert it to work neither with [ pre ] neither with [ code ]
[edited by: BlobFisk at 9:27 am (utc) on June 12, 2004]
[edit reason] Fixed scrolling - \n is a manual line break/ [/edit]
The difference between your function and the one I posted is that yours is going to always break the text at the provided length, regardless of whether or not there are any spaces. The one I posted will look for a space to the left of the maxlength point and break there if one is found.