JS WYSIWYG Editor - Image Alignment...?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Edd

    #1

    JS WYSIWYG Editor - Image Alignment...?

    Hi,

    I have built a basic WYSIWYG HTML editor using Javascript the
    ExecCommand commands.

    What is fustrating me is that, according to the MSDN site, there is no
    way to set the alignment of an image (eg left, right, middle).

    This MUST be possible using Javascript...an d I have thought about
    using the command

    document.iEdito r.imagename.sty le.float = "right"

    BUT...i don't know how to set the 'imagename' above to the image
    currently selected within the editor.

    (FYI 'iEditor' is an iFrame with DesignMode set to 'on')

    If anyone has any ideas about how to go about doing this, it would be
    massively appreciated!!

    Thanks
    Edd
  • HikksNotAtHome

    #2
    Re: JS WYSIWYG Editor - Image Alignment...?

    In article <dd8239c.040108 1519.3b3c39c3@p osting.google.c om>, mail@eddread.co .uk
    (Edd) writes:
    [color=blue]
    >I have built a basic WYSIWYG HTML editor using Javascript the
    >ExecCommand commands.[/color]

    You have built an IE-only HTML Editor.
    [color=blue]
    >What is fustrating me is that, according to the MSDN site, there is no
    >way to set the alignment of an image (eg left, right, middle).
    >
    >This MUST be possible using Javascript...an d I have thought about
    >using the command
    >
    >document.iEdit or.imagename.st yle.float = "right"
    >
    >BUT...i don't know how to set the 'imagename' above to the image
    >currently selected within the editor.[/color]

    That depends on how you are invoking the attempt to align it. If I have an
    image and want to align it, what steps do I have to take? Select the image,
    then click a button? If so, when I make a selection, keep a global variable
    that tracks what is currently selected and then act on it.

    Of course, you would have to ensure that when I try to align an image, that I
    actually have an image selected.

    document.iEdito r.images[imageName].style.float
    and pass imageName as a parameter to it.

    function setImageAlign(i mageName,imgAli gnment){
    document.iEdito r.images[imageName].style.float = imgAlignment;
    }
    --
    Randy

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: JS WYSIWYG Editor - Image Alignment...?

      Edd wrote:
      [color=blue]
      > I have built a basic WYSIWYG HTML editor using Javascript the
      > ExecCommand commands.[/color]

      Yet another one ...
      [color=blue]
      > What is fustrating me is that, according to the MSDN site,[/color]

      URL?
      [color=blue]
      > there is no way to set the alignment of an image (eg left, right, middle).[/color]

      M$ is lying again. You only need to assign the "align"
      property of an HTMLImageElemen t object a proper value.
      [color=blue]
      > This MUST be possible using Javascript...an d I have thought about
      > using the command
      >
      > document.iEdito r.imagename.sty le.float = "right"
      > [...]
      > (FYI 'iEditor' is an iFrame with DesignMode set to 'on')[/color]

      Quickhack (see <http://pointedears.de. vu/scripts/test/whatami>):

      var oImageStyle = document.frames['iEditor'].images[imagename].style;
      oImageStyle.flo at = "right";
      [color=blue]
      > BUT...i don't know how to set the 'imagename' above to the image
      > currently selected within the editor.[/color]

      <computer> Please restate your request. </computer>
      [color=blue]
      > If anyone has any ideas about how to go about doing this, it would be
      > massively appreciated!![/color]

      How much are you going to pay me?


      PointedEars

      Comment

      Working...