Hello,
I've been all over the place looking for an answer. Felt the easiest thing to do is post and see if any of you kind souls had a solution. We have a well oil installation of FCKEditor on our app. However there are a couple weird behaviors that I would like to remedy. This is one. When adding certain Javascript code in SOURCE view I'm finding various results where FCKEditor will transpose the Javascript and therefore render it dead or inoperable. This reveals itself when trying to add a simple script such as an AddThis bookmark.
I switch to SOURCE mode and paste the supplied script from AddThis. Here is the code going in:
<!-- AddThis Button BEGIN --> <script type="text/javascript">var addthis_pub="haddthis";</script> <a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script> <!-- AddThis Button END -->
Here it is after I either toggle from SOURCE to WYSIWYG:
<!-- AddThis Button BEGIN --> <script type="text/javascript">var addthis_pub="haddthis";</script> <a onmouseover="return addthis_open(this, ', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()" href="http://www.addthis.com/bookmark.php?v=20"><img width="125" height="16" alt="Bookmark and Share" style="border:0" src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" /></a><script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script> <!-- AddThis Button END -->
Notice how the <a> tag and it's attributes are handled AND notice the onmouseover event and how ONE of the single quotes of the addthis_open() function has been stripped. It's gone from:
addthis_open(this, '', '[URL]', '[TITLE]')
To
addthis_open(this, ', '[URL]', '[TITLE]')
Is there some obvious solution to this? I can't imagine others have not run into this problem.
I might also add the following scenario that has me stumped.
If I simple paste the supplied code from AddThis.com to the SOURCE view in the editor and either submit OR toggle back to WYSIWYG and THEN back to SOURCE I find that the editor has offered up the following transposed markup:
<!-- AddThis Button BEGIN --> <script type="text/javascript">var addthis_pub="haddthis";</script> <p><a onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()" href="http://www.addthis.com/bookmark.php?v=20"><img width="125" height="16" alt="Bookmark and Share" style="border:0" src="http://s7.addthis.com/static/btn/lg-bookmark-en.gif" /></a><script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script> <!-- AddThis Button END --></p>
Notice the insertion of the <p> and </p> tags. I'm not as concerned about this but this may be relative to the previous issue. I can remedy this by instructing my users to paste any <script></script> markup between <div> tags. This seems to maintain some of the integrity of the JS code. But the fact remains that the empty single quotes seems to be stripped. Or at least one of them.
Any thoughts, help (config settings to consider) would be greatly appreciated.
H
Re: Javascript in Source gets Transposed
Well. I just tried pasting the code into the FCKEditor demo at this address and the same thing happens.
http://www.fckeditor.net/demo
That's disheartening.
Re: Javascript in Source gets Transposed
Am I missing something? No interest in this topic? Is there another thread that I might have missed?
Just wondering. Thanks.
H
Re: Javascript in Source gets Transposed