作者lccf (~(⊙o⊙)~)
看板PHP
标题[问题] iframe focus问题
时间Mon Oct 18 10:35:34 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)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.109.16.211
※ 编辑: lccf 来自: 140.109.16.211 (10/18 10:36)
1F:→ guardlan:你应该去javascript板...XD 10/18 11:35
2F:推 kalecgos0616:请洽Web_Design 10/18 11:49