[請益] iframe focus問題

看板Web_Design作者 (~(⊙o⊙)~)時間15年前 (2010/10/18 12:09), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
想請問一下 如果我希望可以當按下一個圖片時,他就會插入到iframe裡面 然後希望接下來滑鼠游標是自動在iframe那張圖片後, 不用從新再用滑鼠點一次iframe做focus動作 以方便使用者繼續按下他要插入的圖片 不過目前不太曉得要從哪邊加入focus動作 麻煩幫我看一下哪邊有問題 謝謝 <html> <head> <script language="javascript"> function wysiwyg_editor_init(){ document.getElementById("wysiwyg_editor").contentDocument.designMode="on"; document.getElementById("wysiwyg_editor").focus(); } setTimeout("wysiwyg_editor_init()", 1000); function fun(str) { var selection = window.frames["wysiwyg_editor"].getSelection(); var imgElement = document.createElement("img"); imgElement.src=str; selection.getRangeAt(0).surroundContents(imgElement); } </script> </head> <body> <form name="editor_form"> <iframe height="200" width="500" name="wysiwyg_editor" id="wysiwyg_editor" "> </iframe> <br> <div style="width:350px;"> <img src="../images/getTTF1.gif" width="40" height="40" class="img1" onClick="fun(this.src);" style="cursor:pointer;"/> </div> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.109.16.211 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.109.16.211 ※ 編輯: lccf 來自: 140.109.16.211 (10/18 10:32) ※ 編輯: lccf 來自: 140.109.16.211 (10/18 10:35) -- ※ 編輯: lccf 來自: 140.109.16.211 (10/18 12:11)

10/18 13:54, , 1F
document.getElementById("[iframe_ID]").contentDocument
10/18 13:54, 1F

10/18 13:55, , 2F
.getElementById("[要focus的物件ID]").focus();
10/18 13:55, 2F
文章代碼(AID): #1CkyXxNW (Web_Design)