ContentEditable execCommand() alternative?

Discussion in 'JavaScript' started by fluid, Apr 17, 2006.

  1. #1
    I have a contenteditable div on a page. I know there are a few in-built functions (execCommand()) which i can use but i need to be able to insert H5 tags in the contenteditable. So my question is how do i create a custom execCommand to do the H5 for my page. Or any other alternative?
     
    fluid, Apr 17, 2006 IP
  2. torunforever

    torunforever Peon

    Messages:
    414
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe I'm misunderstanding what you're asking, but have you tried this?
    yourObj.execCommand('formatblock', false, '<h5>')
     
    torunforever, Apr 17, 2006 IP
  3. fluid

    fluid Active Member

    Messages:
    679
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #3
    What i really want to do is <h5 class=myclass>my text</h5>.

    I tried yourObj.execCommand('formatblock', false, '<h5 class=myclass>') but it doesnt work. Any ideas?
     
    fluid, Apr 18, 2006 IP
  4. fluid

    fluid Active Member

    Messages:
    679
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #4
    Alrite, i found solution to this.

    Just one little javascript function was enough to do it.

    getElementsByTagName()
    setAttribute()

    thanks anyway torunforever
     
    fluid, Apr 19, 2006 IP