[英]JavaScript:Not able to insert image at cursor position of webview with specific Height and Width
我正在嘗試使用WebView實現RichTextEditor。
我使用以下代碼插入圖像。 運行正常。
webview.loadUrl("javascript:
(function () { document.execCommand('insertImage', 'false','"
+ selectedImagePath +"');})()");
為了指定高度和寬度,我使用了以下命令,但是它不起作用。
String imagSpec = " width=" + 200 + " height=" + 200 + " border= 5" ;
webview.loadUrl("javascript(function () {
document.execCommand('insertImage', 'false','"
+ selectedImagePath +imagSpec+ "');})()");
請幫助我正確地做。
以下代碼為我工作。
String exeSucess="document.execCommand('insertHtml', false,'<img +
src=\"http://www.developphp.com/images/home_over.png\" +
height=200 width=auto style=\"object-fit=contain;\"></img>');";
我沒有使用“ insertImage”命令,而是使用了“ insertHtml”在光標位置插入圖像標簽。
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.