Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to recover the font size

Status
Not open for further replies.

jslmvl

Vendor
Jan 26, 2008
268
GB
Hi,

In a contentEditable <DIV> area, I inserted a big letter by Rng.pasteHTML('<font size=5>A<font>') and it worked good. However, sometimes the letters immediately follow it also became big letter with size=5.

My question would be how to make the font size back to the setting of the <DIV>?

Thanks a lot (and hope you understand what I said).
 
Thank you and sorry!!
I forgot the '/' in above question. However, I did include the '/' in the code running in my PC.
If you like, I can post the whole code for you.
 
OK, this is a simple code, I have just tested in my IE.

<html>
<script>
function Test()
{
document.getElementById("testDiv").focus()
var Rng = document.selection.createRange();
Rng.pasteHTML("<font size=5>A</font>");
}
</script>
<body>
<div id="testDiv" contentEditable="true"></div>
<input type="button" onclick="Test()">
</body>
</html>

Please let me know If anything wrong in the code.

What I tested by this code is:
Type ABC, click the button, the big A appears, press Return, put the cursor immediately after the big A, then type a letter and this letter is a big letter!
 
I'm not 100% sure about this, but my gut feeling is there's not much you can do about this.

I say this because any preventative measures might also knock out genuine text with a bigger font size.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Thank you.

If my problem may not be solved, can we think another way:
a javascript function that says "all the typed in letters for the DIV will be with font-size=14px"?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top