开发者

Change text direction in iframe dynamically

I want to be able to change text direction, per line, inside iframe's document.

Like in Gmail compose mail textbox.

(By the way how Gmail accomplish that?)

For now I define this:

iframe's outerHTML =
    "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" +
    "<html xmlns='http://www.w3.org/1999/xhtml'>" +
    "<head>" + meta +
    "<title>Design Editor Frame</title>" +
    "<style type='text/css'>" +
    "body {background-color:White;}*{cursor:text;}p {margin:0;}" +
    "</style>" +
    "</head>" +
    "<body></body>" +
    "</html>";

designMode ="on"

Update:

Maybe I do can something like this, intercept 'Enter' keypress in iframe开发者_如何学运维, and then wrap the new line with 'p' tag.

And on p tag I can apply the dir.


getElementById("your_element").dir="rtl"

You're probably need something more complex, to handle every element even when you have no ID's, so I'd recommend you to use jQuery javascript library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜