澳门新浦京8455com网站建设-个人小白,对jsp不太熟悉,做一个网站,遇到了点问题,在线等牛人解答

近来在做网址的时候,开掘eWebEditor在线文本编辑器不扶助IE9,点击编辑器中的开关都未有影响,早先本站揭橥过一篇《消除IE8不援救eWebEditor在线文本编辑器的章程》,但貌似在IE9下方法就失效了,在网络找到了终级肃清方法,拿来给大家享用。

个人小白,对jsp不太熟谙,做多少个网址,蒙受了点难题,在线等牛人解答
SEP_PADDING = 5;
HANDLE_PADDING = 7;

1.风云目的: 事件目标 target –> event.target  真正触发事件的目的

包容性写法

正规浏览器:event.target

IE6、7、8: event.srcElement

var target = event.target || event.srcElement;

先是找到eWebEditor编辑器所在的目录,然后寻找到editor.js文件并用文件编辑器张开,然后找到BtnMouseUp(State of Qatar函数,将该函数代码替换来如下代码就可以:复制代码 代码如下:function BtnMouseUp(卡塔尔 { if
(event.srcElement.tagName != “IMG”) { event.cancelBubble = true; return
false; }

var yToolbars = new Array();

2.增添平地风波的新议程

1.经过丰硕事变监听器的诀要注册事件:add伊芙ntListener

参数1:事件名称    参数2:事件管理函数    参数3:是不是选用捕获

2、IE678增添事件监听器:attachEvent(事件名称,事件管理函数 State of Qatar

代码写法

var btn1 = document.getElementById(“btn1”);

var btn2 = document.getElementById(“btn2”);

btn1.attachEvent(“onclick”,function(卡塔尔{alert(“1″卡塔尔}卡塔尔(قطر‎//ie6.7.8可接纳,Google不用选拔

btn2.addEventListener(“click”,function(卡塔尔(قطر‎{alert(“2″卡塔尔},falseState of QatarGoogle可接纳

注意事项:

attachEvent 用onclick,三个参数

add伊芙ntListener 用click,多少个参数

无论是onclick依然click都以字符串,要求增添””

宽容性全体浏览器的函数写法

//封装 宽容全数浏览器的拉长事件的函数

//element要绑定事件的成分对象 eventName是字符串而且不加on
listener事件管理函数

function addEvent(element, eventName, listener) {

if (element.addEventListener) {

element.addEventListener(eventName, listener, false);

} else if (element.attachEvent) {

element.attachEvent(“on” + eventName, listener);

} else {

//element.onclick = listener;

//element[“onclick”] = listener;

element[“on” + eventName] = listener;

}

}

var image = event.srcElement; var element = image.parentElement;

var YInitialized = false;

3.移除事件的新点子

  1. 再也定义,覆盖前面包车型客车登记事件

  2. 移除事件监听器:

removeEventListener  参数与绑定期同样

detachEvent          IE678

宽容性全数浏览器的函数写法

封装 宽容全体浏览器的移除事件的函数

function removeEvent(element, eventName, listener) {

if (element.removeEventListener) {

element.removeEventListener(eventName, listener, false);

} else if (element.detachEvent) {

element.detachEvent(“on” + eventName, listener);

} else {

element[“on” + eventName] = null;

}

}

事件指标的相称管理

1、获取事件指标:get伊夫nt

2、获取鼠标页面座标: pageX、pageY

3、阻止冒泡函数 stopPropagation( State of Qatar

4、重临事件目的:getTarget

代码如下:

document.onclick = function (event) {

var event = getEvent(event);

var pageX = getPageX(event);

var pageY = getPageY(event);

stopPropagation(event);

var target = getTarget(event);

};

//封装获取事件指标的拾叁分方式

function getEvent(event) {

return event || window.event;

}

//封装获取鼠标在页面上的档案的次序坐标的十一分格局

function getPageX(event) {

return event.pageX || event.clientX +
document.documentElement.scrollLeft;

}

//封装获取鼠标在页面上的竖直坐标的相称方式

function getPageY(event) {

return event.pageY || event.clientY +
document.documentElement.scrollTop;

}

//封装阻止冒泡的相配情势

function stopPropagation(event) {

if (event.stopPropagation) {

event.stopPropagation();

} else {

event.cancelBubble = true;

}

}

//封装获取事件目的的相当方式

function getTarget(event) {

return event.target || event.srcElement;

}

事件指标宽容管理的愈益封装

  1. 宣示叁个对象:eventUtil 来存款和储蓄方法

  2. 刚巧的相当方法都写在目的里面

  3. 利润:  1.有益于  2.防止了全局变量的命名矛盾污染

document.onclick = function (event) {

var event = eventUtils.getEvent(event);

var pageX = eventUtils.getPageX(event);

var pageY = eventUtils.getPageY(event);

eventUtils.stopPropagation(event);

var target = eventUtils.getTarget(event);

};

var eventUtils = {

getEvent: function (event) {

return event || window.event;

},

getPageX: function (event) {

return event.pageX || event.clientX +
document.documentElement.scrollLeft;

},

getPageY: function (event) {

return event.pageY || event.clientY +
document.documentElement.scrollTop;

},

stopPropagation: function (event) {

if (event.stopPropagation) {

event.stopPropagation();

} else {

event.cancelBubble = true;

}

},

getTarget: function (event) {

return event.target || event.srcElement;

}

};

try{ if (element.YUSERONCLICK) eval(element.YUSERONCLICK +
“anonymous()”); } catch(e){ if (element.YUSERONCLICK)
eval(element.YUSERONCLICK + “onclick(event)”); }

function temp()
{

4.鼠标事件和键盘事件

1、onkeydown:键盘按下一致  摁下不放一贯实行

2、onkeypress:键盘按下  onkeydown最本色的分别是键盘码

3、onkeyup:键盘弹起

4、onkeydownonkeyup使用的是键盘码  onkeypress使用的是Ascll码

element.className = “BtnMouseOverUp”; image.className = “Ico”;

}
function insertHtml
{
var
win=window.editor.Composition.document;//当中编辑区域是gledit.jsp中的二个iframe,id是idEditbox
window.editor.Composition.focus(卡塔尔(قطر‎;//是编辑器获得主旨,防止代码插入在编写制定器内地点
win.selection.createRange(卡塔尔.pasteHTML;//在光标的岗位插入html代码
}

5.按回车键切换文本框

1、检查测量试验按下的是哪个键:e.keyCode === 13

2、成分获得关节:obj.focus(卡塔尔;

event.cancelBubble = true; return
false;}表达:以上代码淡金黄部分为eWeb艾德itor在线文本编辑器包容IE9IE8的为主代码,我们也足以依靠实际情形更动BtnMouseUp(卡塔尔国函数中的相应代码。

function document.onreadystatechange()
{
if (YInitialized) return;
YInitialized = true;

6.按esc关闭

1、检查实验按下的键对应的值:e.keyCode === 27

2、键盘按钮对  就隐蔽盒子

7.表单事件

onfocus 获取关节

onblur 失去宗旨

oninput 在输入的时候实行

onchange 失去主题后一旦表单成分的内容爆发了改造 那个时候就能够施行

小提醒:假设您的eWebEditor在线文本编辑器版本过老,在IE9下根本都力不从心展开eWebEditor分界面,你可以在IE9中设置成浏览器宽容情势,就能够平日在IE9中选择eWeb艾德itor了。

var i, s, curr;

for (i=0; i<document.body.all.length; i++)
{
curr=document.body.all[i];
if (curr.className == “yToolbar”)
{
InitTB;
yToolbars[yToolbars.length] = curr;
}
}

DoLayout();
window.onresize = DoLayout;

Composition.document.open();
Composition.document.write(“

body {font-size: 10.8pt}”);
Composition.document.close();
Composition.document.designMode=”On”;
}

function InitBtn
{
btn.onmouseover = BtnMouseOver;
btn.onmouseout = BtnMouseOut;
btn.onmousedown = BtnMouseDown;
btn.onmouseup = BtnMouseUp;
btn.ondragstart = YCancelEvent;
btn.onselectstart = YCancelEvent;
btn.onselect = YCancelEvent;
btn.YUSERONCLICK = btn.onclick;
btn.onclick = YCancelEvent;
btn.YINITIALIZED = true;
return true;
}

function InitTB
{
y.TBWidth = 0;

if (! PopulateTB return false;

y.style.posWidth = y.TBWidth;

return true;
}

function YCancelEvent()
{
event.returnValue=false;
event.cancelBubble=true;
return false;
}

function BtnMouseOver()
{
if (event.srcElement.tagName != “IMG”) return false;
var image = event.srcElement;
var element = image.parentElement;

if (image.className == “Ico”) element.className = “BtnMouseOverUp”;
else if (image.className == “IcoDown”) element.className =
“BtnMouseOverDown”;

event.cancelBubble = true;
}

function BtnMouseOut()
{
if (event.srcElement.tagName != “IMG”) {
event.cancelBubble = true;
return false;
}

var image = event.srcElement;
var element = image.parentElement;
yRaisedElement = null;

element.className = “Btn”;
image.className = “Ico”;

event.cancelBubble = true;
}

function BtnMouseDown()
{
if (event.srcElement.tagName != “IMG”) {
event.cancelBubble = true;
event.returnValue=false;
return false;
}

var image = event.srcElement;
var element = image.parentElement;

element.className = “BtnMouseOverDown”;
image.className = “IcoDown”;

event.cancelBubble = true;
event.returnValue=false;
return false;
}

function BtnMouseUp()
{
if (event.srcElement.tagName != “IMG”) {
event.cancelBubble = true;
return false;
}

var image = event.srcElement;
var element = image.parentElement;

if (element.YUSERONCLICK) eval(element.YUSERONCLICK + “anonymous;

element.className = “BtnMouseOverUp”;
image.className = “Ico”;

event.cancelBubble = true;
return false;
}

function PopulateTB
{
var i, elements, element;

elements = y.children;
for (i=0; i<elements.length; i++) {
element = elements[i];
if (element.tagName == “SCRIPT” || element.tagName == “!”) continue;

switch (element.className) {case "Btn": if (element.YINITIALIZED == null) { if (! InitBtn return false; } element.style.posLeft = y.TBWidth; y.TBWidth += element.offsetWidth + 1; break;case "TBGen": element.style.posLeft = y.TBWidth; y.TBWidth += element.offsetWidth + 1; break;case "TBSep": element.style.posLeft = y.TBWidth + 2; y.TBWidth += SEP_PADDING; break;case "TBHandle": element.style.posLeft = 2; y.TBWidth += element.offsetWidth + HANDLE_PADDING; break;default: return false;}

}

y.TBWidth += 1;
return true;
}

function DebugObject
{
var msg = “”;
for (var i in TB) {
ans=prompt(i+”=”+TB[i]+”n”);
if break;
}
}

function LayoutTBs()
{
NumTBs = yToolbars.length;

if (NumTBs == 0) return;

var i;
var ScrWid = (document.body.offsetWidth) – 6;
var TotalLen = ScrWid;
for (i = 0 ; i < NumTBs ; i++) {
TB = yToolbars[i];
if (TB.TBWidth > TotalLen) TotalLen = TB.TBWidth;
}

var PrevTB;
var LastStart = 0;
var RelTop = 0;
var LastWid, CurrWid;

var TB = yToolbars[0];
TB.style.posTop = 0;
TB.style.posLeft = 0;

var Start = TB.TBWidth;
for (i = 1 ; i < yToolbars.length ; i++) {
PrevTB = TB;
TB = yToolbars[i];
CurrWid = TB.TBWidth;

if ((Start + CurrWid) > ScrWid) { Start = 0; LastWid = TotalLen - LastStart;}else { LastWid = PrevTB.TBWidth; RelTop -= TB.offsetHeight;}TB.style.posTop = RelTop;TB.style.posLeft = Start;PrevTB.style.width = LastWid;LastStart = Start;Start += CurrWid;

}

TB.style.width = TotalLen – LastStart;

i–;
TB = yToolbars[i];
var TBInd = TB.sourceIndex;
var A = TB.document.all;
var item;
for {
item = A.item;
if continue;
if (! item.style) continue;
if (item.sourceIndex <= TBInd) continue;
if (item.style.position == “absolute”) continue;
item.style.posTop = RelTop;
}
}

function DoLayout()
{
LayoutTBs();
}

function validateMode()
{
if (! bTextMode) return true;
alert(“请裁撤“使用 HTML 语法书写”选项再选拔系统一编写制成效!”);
Composition.focus();
return false;
}

function format1
{
if (opt==”removeFormat”)
{
what=opt;
opt=null;
}

if (opt==null) Composition.document.execCommand;
else Composition.document.execCommand(what,””,opt);

pureText = false;
Composition.focus();
}

function format
{
if (!validateMode return;

format1;
}

function setMode
{
bTextMode = newMode;
var cont;
if (bTextMode) {
cleanHtml();
cleanHtml();

cont=Composition.document.body.innerHTML;Composition.document.body.innerText=cont;

} else {
cont=Composition.document.body.innerText;
Composition.document.body.innerHTML=cont;
}

Composition.focus();
}

function getEl(sTag,start)
{
while ((start!=null) && (start.tagName!=sTag)) start =
start.parentElement;
return start;
}

function UserDialog
{
if (!validateMode return;

Composition.document.execCommand(what, true);

pureText = false;
Composition.focus();
}

function foreColor()
{
if (! validateMode return;
var arr = showModalDialog(“selcolor.htm”, “”, “dialogWidth:18.5em;
dialogHeight:17.5em; status:0”);
if (arr != null) format(‘forecolor’, arr);
else Composition.focus();
}

function fortable()
{
if (! validateMode return;
var arr = showModalDialog(“table.htm”, “”, “dialogWidth:18.5em;
dialogHeight:11.5em; status:0”);

if (arr != null){
var ss;
ss=arr.split
row=ss[0];
col=ss[1];
var string;
string=”

“;
for(i=1;i<=row;i++){
string=string+”

“;
for(j=1;j<=col;j++){
string=string+”

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图