Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在所见即所得编辑器中调整图像大小_Javascript_Html_Wysiwyg - Fatal编程技术网

Javascript 在所见即所得编辑器中调整图像大小

Javascript 在所见即所得编辑器中调整图像大小,javascript,html,wysiwyg,Javascript,Html,Wysiwyg,我正在为我的网站构建所见即所得编辑器。我想能够在用户将图像插入文本时调整图像大小。怎么做?此代码不起作用 这就是我使用的代码 function iImage(){ var imgSrc = prompt('Enter image location', ''); imgSrc.style.height='100px'; imgSrc.style.width='50px'; if(imgSrc != null){ richTextField.docume

我正在为我的网站构建所见即所得编辑器。我想能够在用户将图像插入文本时调整图像大小。怎么做?此代码不起作用

这就是我使用的代码

function iImage(){  
   var imgSrc = prompt('Enter image location', '');  
   imgSrc.style.height='100px';
   imgSrc.style.width='50px';
   if(imgSrc != null){
       richTextField.document.execCommand('insertimage', false, imgSrc);   
   }
}

我不知道您正在构建什么样的WYSIWYG编辑器,也不知道这些函数在做什么,不过我建议您尝试设置高度和宽度属性,而不是样式

function iImage(){  
   var imgSrc = prompt('Enter image location', '');  
   imgSrc.height='100px';
   imgSrc.width='50px';
   if(imgSrc != null){
       richTextField.document.execCommand('insertimage', false, imgSrc);   
   }
}
对应的HTML应该是

<img src="..." height="100px" width="500px">

不是


编辑:

您可以在此处找到解决方案:

坏消息:您必须编写比这多得多的代码才能使其正常工作。请编辑我的代码。它不起作用。为什么人们不喜欢这篇文章?我相信这是因为你的代码中没有与调整图像大小相关的内容。我使用了WYSIWYG富文本HTML编辑器,所以这段代码不能放入WYSIWYG。等等,我以为你说你在构建WYSIWYG?你能给你正在使用的编辑器一个长度吗?我的意思是我建立了WYSIWYG富文本HTML编辑器。当编辑器将图像转换为文本时,它会转换为原始大小。所以我想在WYSIWYG富文本HTML编辑器中确定图像大小请参见我的编辑中的链接,它提供了一个可能适合您的解决方案谢谢您的工作。有人不喜欢我的问题,但你帮了我,非常感谢:)
<img src="..." style="height100px;width:500px;">