作者lccf (~(⊙o⊙)~)
看板Ajax
标题[请益] iframe focus问题
时间Mon Oct 18 10:32:07 2010
想请问一下
如果我希望可以当按下一个图片时,他就会插入到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:转录至看板 PHP 10/18 10:35
1F:→ mesak:哪个编辑器?? 有些编辑器有特殊的写入法 10/18 16:40