Hi there:
I am running FCKEditor 2.6.4 and am looking for a solution to insert onClick and onMouseOver external javascript into the anchor tags of my editor instances.
This insertion would be handled via a toolbar button.

What I already know and have tried:
1. Know how to manually do this task in source view.
2. Already created the 2 javascripts I want to use, and proven they work when I insert the script in the editors source mode.
3. Already started making the plugin, but I'm lost on making the actual processing file as I do not want a dialogue window, just have the user click the button in the toolbar.
4. Already have created my fckplugin.js file and toolbar button.

As an example, here is what I have accomplished:
The standard image with its link is:

<a class="fadeit" target="_self" href="anotherpage.php"><img border="0" hspace="1" alt="" width="181" height="43" src="pathto/image.png" /></a>

I already have a style class for the link, the styleclass sets 50% opacity until hovered at 100% opactiy, that was easily accomplished by applying the style to the Insert/Edit Link > advanced tab (after setting it in the editor stylesheet).

Here is what I'm trying to accomplish:
We start out with the same linked and styled image...

<a class="fadeit" target="_self" href="anotherpage.php"><img border="0" hspace="1" alt="" width="181" height="43" src="pathto/image.png" /></a>

The user clicks the plugin toolbar button and the link source code is modified to the following:

<a class="fadeit" onclick="clickit('anotherpage.php', 'targetwin will be _parent'); return false" onmouseover="hoverit('picpath/pic.png', 'targetdiv'); return false"><img border="0" hspace="1" alt="" width="181" height="43" src="pathto/image.png" /></a>

Any help or advice for this FCKEditor plugin would be great.

Best regards,
dennishall

I would think that FckEditor website should have a forum or tutorial for this. I never used FckEditor but tinyMCE. Their website has a wiki and explain how to add your own button/functionality. I would expect FckEditor to have some sort of information as well because it has been existing for longer than tinyMCE.

Thanks for this reply Taywin:

Yes, FCK has a website for these type questions as I have posted there as well, however, my plugin question is related only to creating a function for the code above, that will insert the onClick function into the A tag of an href associated with an IMG tag.

Please excuse me for not being as clear as I should have been on the challenge.

A detailed description:

<a class="fadeit" target="_self" href="anotherpage.php"><img border="0" hspace="1" alt="" width="181" height="43" src="pathto/image.png" /></a>

Is an existing script.

If a user clicks on the image(image.png) they can click a button to insert the onClick function into the A tag associated with the image.
Clicking a button will insert:

onclick="clickit('anotherpage.php', 'targetwin will be _parent'); return false" onmouseover="hoverit('picpath/pic.png', 'targetdiv'); return false"

into the <A tag either before or after the style class="fadeit".

The editor I use is actually irrelevant, as I have already created the code to insert the button in the editor and to call the function, so...
My better defined question is:
Can anyone assist me in creating a script that will insert the onclick function into an Anchor tag based on the associated image being selected and a button being pressed?

Best Regards,
dennishall

Can anyone assist me in creating a script that will insert the onclick function into an Anchor tag based on the associated image being selected and a button being pressed?

I am sorry for not understanding what you asked for. Also, the question quoted above, I am still guessing that you want a script that can attach an event 'onclick' on the fly (on an image or button), and the script should work similar to an anchor tag (redirect to a page)?

I was able to resolve this issue by developing scripts that would insert each function into the A tag. I then modified the editor layout to add the new buttons.

Grate :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.