<IMG src="http://192.168.0.3/jingjib/admin/upfile/20050224093347-0.jpg" id="myimg">
<script language="javascript">
    document.all.myimg.align = "left";
</script>

解决方案 »

  1.   

    关键是我的图片时通过
    window.opener.frames.message.document.execCommand('InsertImage', false, imagePath);
    插入的。这个命令不能进行参数添加!
      

  2.   

    试试这个吧,我没有测试,但愿能行~~window.opener.frames.message.document.execCommand('InsertImage', false, imagePath);
    var obj = null;
    for(var i=document.images.length; i>=0; i--)if(document.images[i].src==imagePath)obj=document.images[i];
    if(obj)obj.align = "left";
      

  3.   

    遍历错地方了吧,for(var i=window.opener.frames.message.document...
      

  4.   

    哦,对对,谢谢 sfply(随风飘零叶) 指正!!!
      

  5.   

    //居中
    window.opener.frames.message.document.execCommand('justifycenter', , null);
    //居左
    window.opener.frames.message.document.execCommand('justifyleft', , null);
    //居右
    window.opener.frames.message.document.execCommand('justifyright', , null);
    //两端对齐
    window.opener.frames.message.document.execCommand('justifyfull', , null);
      

  6.   

    多谢各位!
    楼上的没有看明白我的意思:window.opener.frames.message.document.execCommand('justifyleft', , null);结果是:
    <P align=left><IMG src="http://192.168.0.3/jingjib/admin/upfile/20050224093347-0.jpg"></P>GageCSDN(稻草人) sfply(随风飘零叶) 还没有解决我的问题:window.opener.frames.message.document.execCommand('InsertImage', false, imagePath);已经插入到编辑器中了,如果只设定图片的if(obj)obj.align = "left";没有实现功能。
    我想在代码中添加:align='left'到现在还没有解决方法.
      

  7.   

    你选中图片再点execCommand('jsutifyleft',,)不就行了嘛
      

  8.   

    那样可能就要自己写个脚本插入图片了,如下:
    <html>
    <head>
    <script>
    function insertImage(imagePath){
    iEdit.focus();
    document.selection.clear;
    obj1=iEdit.document.selection.createRange()
    obj1.pasteHTML("<img src="+imagePath+" align='left'>");
    }
    </script>
    </head>
    <body LANGUAGE=javascript onload="iEdit.document.designMode='on'">
    <iframe id=iEdit></iframe>
    <input type=button onclick=insertImage("http://community.csdn.net/images/CSDN_logo.GIF")>
    </body>
    </html>