/    Sign up×
Community /Pin to ProfileBookmark

attach eventhandler to rte

How can I make this code work inside the rich text editor?

function whichElement(e)
{
rte = currentRTE;

var targ;
if (!e)
{
var e = window.event;

}
if (e.target)
{
targ=e.target;
}
else if (e.srcElement)
{
targ=e.srcElement;
}
if (targ.nodeType==3) // defeat Safari bug
{
targ = targ.parentNode;
}
var imgRTE = document.getElementById(“rteTableButton1”);
imgRTE.style.border = ‘2px blue solid’;

//var tname;
//tname=targ.tagName;
//alert(“You clicked on a ” + tname + ” element.”);
};

rtehtml += ‘<iframe onfocus=”dlgCleanUp();” id=”iframe’+rte+'” onmousedown=”whichElement(event);” frameborder=”0″ src=”‘ + includesPath + ‘blank.htm” style=”top:0px;’;

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 06.2008 — You probably want to attach the event to 'blank.htm' rather than the iframe
Copy linkTweet thisAlerts:
@tskaarauthorApr 06.2008 — I allready tried the "blank.htm", but it`s only a dummy-page. It does nothing.

The code where the content show looks like this:

<script type="text/javascript"><!--

//Usage: writeRichText(fieldname, html, css_override, width, height, buttons, readOnly, fullscreen)

writeRichText('rte1', '<%=sContent %>', '', 650, 400, true, false, false);

//--></script>

"rte1" is the id of the iframe.
×

Success!

Help @tskaar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...