|
-
Aug 14th, 2011, 11:44 AM
#1
Thread Starter
Junior Member
Firefox HTML Code
Okay,
So I have a script in Javascript, which basically puts a textbox on a popup.
And then writes some text in it.
e.g.
HTML Code:
<textarea cols=80 rows=10 onFocus='this.select()'>
[img]justexthere¢rex=500moretextnow[/img]
</textarea>
However, my problem is that it changes the "¢" to a HTML code of: ¢. Which I have no idea how to stop this, so can anyone tell me how please
-
Aug 14th, 2011, 04:34 PM
#2
Addicted Member
Re: Firefox HTML Code
Hello
That's because the browser will automatically use the HTML entities
to solve this problem, you should give the '[img].....' like text plain using javascript, at the same time there are different ways according to the browser
for firefox, use this script line:
HTML Code:
<script type="text/javascript">
document.getElementById('textareaid').textContent = '[img]http://www.vbforums.com/[/img]';
// textContent turned to innerText in IE
</script>
if you don't want to check the browser to define what property will you use, this has a solution too 
include jQuery and use the function text() like this way:
HTML Code:
<script type="text/javascript">
$('#textareaid').text('[img]http://www.vbforums.com/[/img]').html();
</script>
regards 
Feras Jobeir
Last edited by fjober; Aug 14th, 2011 at 04:37 PM.
-
Aug 15th, 2011, 11:38 AM
#3
Re: Firefox HTML Code
Convert HTML entities:
Code:
function htmlEntities(str) {
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
Usage:
Code:
alert(htmlEntities("¢rex"));
From CSS Tricks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|