jaysoffian
01-12-2004, 01:04 PM
When you submit a hint in HTML, you can get less than ('<') and greater than ('>') symbols to appear properly in the rendered HTML by using the HTML entities < and >
So you type in your hint using the HTML entities and then click "preview". The HTML preview renders as expected, with a less than or greater than symbol in place of the raw HTML entity. However, browsers (tested with both Safari and Mozilla) also translate the raw HTML entities in the default text for the textarea form input field into the corresponding less than and greater than symbols. If you don't go through the text field and translate all those back into the raw HTML entity, when you click submit, your final hint ends up with those symbols not being rendered since they will most likely appear as unknown HTML tags.
As a test, preview a simple hint supplying '<foobar>' as the hint contents. Click preview. Notice that the preview renders as expected: "<foobar>". Notice also that the textarea also renders as "<foobar>". What do you think will happen if you click preview again? But before doing that, view the source for the preview'ed hint. Search for "foobar" twice and notice that the <textarea> is:
<textarea name="introtext" cols="55" rows="12" wrap="virtual"><foobar></textarea>
Unfortunately, both Mozilla and Safari render this text area substituting less than and greater than symbols for the HTML entities.
This makes the preview system difficult to use. In my case, I edit my HTML in an external editor and cut and paste it into the text area box. I then click preview, and if it looks correct, replace the text area box that the browser rendered (and munged) by cutting and pasting my hint in again. I then click Post. If I need to make changes, I make then in the external editor, cut and paste again, etc.
I can think of two solutions:
1) Change the workflow. So user enters text, clicks preview, if it looks right, clicks post. There is no opportunity to re-enter the text directly on the preview page. If they don't like the preview, then they click back in their browser to make changes. You'd have to store the hint on the server side, or use a hidden form field which shouldn't get munged by the browser (base64 encode it if you have too...).
2) Double escape the less than and greater than signs in the textarea sent to the browser. In this case, the textarea would have to look like this:
<textarea name="introtext" cols="55" rows="12" wrap="virtual">&amp;gt;foobar&amp;lt;</textarea>
(Geez, I had to double-escape my double-escapes to get the amp entity to render right in this forum ... sheesh)
j.
So you type in your hint using the HTML entities and then click "preview". The HTML preview renders as expected, with a less than or greater than symbol in place of the raw HTML entity. However, browsers (tested with both Safari and Mozilla) also translate the raw HTML entities in the default text for the textarea form input field into the corresponding less than and greater than symbols. If you don't go through the text field and translate all those back into the raw HTML entity, when you click submit, your final hint ends up with those symbols not being rendered since they will most likely appear as unknown HTML tags.
As a test, preview a simple hint supplying '<foobar>' as the hint contents. Click preview. Notice that the preview renders as expected: "<foobar>". Notice also that the textarea also renders as "<foobar>". What do you think will happen if you click preview again? But before doing that, view the source for the preview'ed hint. Search for "foobar" twice and notice that the <textarea> is:
<textarea name="introtext" cols="55" rows="12" wrap="virtual"><foobar></textarea>
Unfortunately, both Mozilla and Safari render this text area substituting less than and greater than symbols for the HTML entities.
This makes the preview system difficult to use. In my case, I edit my HTML in an external editor and cut and paste it into the text area box. I then click preview, and if it looks correct, replace the text area box that the browser rendered (and munged) by cutting and pasting my hint in again. I then click Post. If I need to make changes, I make then in the external editor, cut and paste again, etc.
I can think of two solutions:
1) Change the workflow. So user enters text, clicks preview, if it looks right, clicks post. There is no opportunity to re-enter the text directly on the preview page. If they don't like the preview, then they click back in their browser to make changes. You'd have to store the hint on the server side, or use a hidden form field which shouldn't get munged by the browser (base64 encode it if you have too...).
2) Double escape the less than and greater than signs in the textarea sent to the browser. In this case, the textarea would have to look like this:
<textarea name="introtext" cols="55" rows="12" wrap="virtual">&amp;gt;foobar&amp;lt;</textarea>
(Geez, I had to double-escape my double-escapes to get the amp entity to render right in this forum ... sheesh)
j.