By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,846 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,846 IT Pros & Developers. It's quick & easy.

Problem: Safari inserting br tags where textarea wraps...

P: 2
Hello all,

built a simple site using a CMS combining MySQL for the back end and PHP to display it all. I have an admin page that has a form comprising of several textareas so the client can update the contents of the site himself.

Any formatting - eg. user line breaks - is inserted into the database and works a-ok. However, when using Safari (I'm running OS X 10.5.1 and Safari 3.0.4), all the line-ends - ie. where the text wraps in the individual textareas - are somehow inserted into the database as <br>. This bug only occurs in Safari.

I have wasted an hour on this and I cannot find any solutions online that work for me. I found a thread with someone who had a similar problem, and the suggestion was to make sure to insert
Expand|Select|Wrap|Line Numbers
  1. wrap="soft"
or
Expand|Select|Wrap|Line Numbers
  1. wrap="virtual"
in order to prevent Safari displaying this behavior. Unfortunately, that does not work for me.

I was hoping that someone here would have come across this problem before and could tell me why this is happening / a solution. To reiterate, there are no problems with the coding of the page as this is only happening in safari, not IE6/7 or Firefox.

Cheers
Jan 6 '08 #1
Share this Question
Share on Google+
4 Replies


drhowarddrfine
Expert 5K+
P: 7,435
I found a thread with someone who had a similar problem, and the suggestion was to make sure to insert
Expand|Select|Wrap|Line Numbers
  1. wrap="soft"
or
Expand|Select|Wrap|Line Numbers
  1. wrap="virtual"
in order to prevent Safari displaying this behavior. Unfortunately, that does not work for me.
Considering the fact that there is no such thing as "wrap", yes, it won't work.

No browser generates html on its own. This problem must lie elsewhere.
Jan 6 '08 #2

P: 2
Considering the fact that there is no such thing as "wrap", yes, it won't work.

No browser generates html on its own. This problem must lie elsewhere.
I realise that this code is depreciated. However, it was suggested that this may work anyway. The problem clearly lies with the browser as all the other browsers behave exactly as they should. Does anyone else have a helpful suggestion?
Jan 7 '08 #3

drhowarddrfine
Expert 5K+
P: 7,435
I realise that this code is depreciated.
You can't deprecate something that never existed. This is an IE only attribute which I never even heard of until I just now Googled. afaik, no other browser supports it.
The problem clearly lies with the browser
Then please tell us how any browser generates markup all by itself.
as all the other browsers behave exactly as they should. Does anyone else have a helpful suggestion?
If you want to continue to live in a world of made up attributes, no one can help you.
Jan 7 '08 #4

P: 26
I think drhowarddrfine is always helpful like that. The wrap attribute not only exists as a proposed standard (proposed by Netscape for HTML 3.0), but it has even been implemented by Netscape, Firefox, Safari, and IE (at least, I don't know about which others). The term deprecation is used to indicate discouragement of usage of a particular software feature, usually because it has been superseded by a newer/better version. Which doesn't have anything to do with standards. The only one living in a made up world is drhowarddrfine himself.

It does sound entirely possible that when form data is posted to the server that Safari takes the visual data from the form and converts it to different markup than the other browsers do. However I've never heard of it happening, and I can't repeat it. Setting the wrap attribute to "hard" makes it send the line breaks from the user's GUI display of the textbox. But I can't see anything that would make it convert those to <br> tags.

Perhaps a little more information is in order.

Are these text-wrap line breaks, carriage return line breaks, or both?
Is this Strict or Quirks mode and what Doctype are you using, if using one at all?
What attributes did you use on the form tag and textarea tag?
Are you certain that there is not some kind of server-side post processing of the form data taking place. It's possible that Safari adds a different kind of line-break than the other browsers and your script converts that to <br> while the other scripts don't. Just make sure we know what we're looking for. An easy way to check would be to dump the POST or GET data as soon as it is received and view the source to see if the <br> tags are already in there or not.

You also should be aware that something like <textarea>Line One<br>Line Two</textarea> will display <br> on the screen instead of a line break and will send it to the database as well.
Jan 7 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.