Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

TinyMCE strips my code


Go to End


27 Posts   19225 Views

Avatar
Lukef

Community Member, 32 Posts

12 May 2009 at 6:19pm

Edited: 12/05/2009 6:20pm

Sorry to dredge this thread up... but I am having the same issue (not being able to add JS) and the advice given does not seem to be working in my case...

The problem looks a little like this...
Correct, working code

<ul class="hoverbox">
<li><img  src="assets/specimages/_resampled/ResizedImage10067-3.jpg" alt="description" onmouseover=show_200("assets/specimages/3.jpg","image_3",418,280) onmouseout=hide_div() onerror=gag(this,100) ></li>
</ul>

The Code after SS/TinyMCE is finished with it.

<ul class="hoverbox">
<li><img onmouseover="show_200("assets/specimages/3.jpg","image_3",418,280)" onmouseout="hide_div()" src="assets/specimages/_resampled/ResizedImage10067-3.jpg" alt="description" ></li>
</ul>

What you see there, is still the result after commenting out the lines recommended by Banal.

Avatar
bummzack

Community Member, 904 Posts

12 May 2009 at 6:35pm

Hi

Your code is actually not correct... although it's working (not in all browsers I presume).
The event attributes should look like this:

onmouseover="show_200('assets/specimages/3.jpg', 'image_3', 418, 280)"

Use double quotes to wrap the whole event argument, then use single quotes for the parameters.
AFAIK, the onerror event attribute is not part of the current html standard (4.0). What's the purpose of this "gag" function you call there?

Avatar
Lukef

Community Member, 32 Posts

12 May 2009 at 6:45pm

Thanks for your speedy reply Banal, here is the truth of it. i don't know anything useful about JS, however, i know a guy who does, and i asked him to create some simple image rollover pop-ups for me he did so but when he discovered SS "cleaned" the code, rather than fix it, he disabled TinyMCE altogether and input the code.

This works in FF3 ie7 and ie6 in a nearly uniform way, but it is of course now no use to the guy i am building it for as he cannot edit any of his site without knowledge of HTML (which he does not possess) SO i am trying to un-break the editor without breaking the code that is already there... so as you could imagine... all help gratefully received... i am a Designer, not a Developer.

so as to the "Why's" of the code, i have no idea. :-/

|G|

Avatar
bummzack

Community Member, 904 Posts

12 May 2009 at 6:57pm

I see. I really doubt, that the onerror event will even be fired.. so there's not much sense in including this.
You should be able to enter your code in TinyMCE if you stick to the quotation rules I posted (http://www.w3schools.com/HTML/html_attributes.asp). Attributes without quotes.. that's coming straight from the nineties :)

If you're using these scripts for a lot of images, it would be a lot easier if you (your programmer) wrote some jQuery functions that add the event handlers to the elements automatically (on page load).

Avatar
Lukef

Community Member, 32 Posts

14 May 2009 at 12:11pm

Thanks for he advice Banal
but it still seems to be butchering the code... though to a lesser extent (or should that be ok?)

code i entered:

<ul class="hoverbox">
<li><img  src="assets/specimages/_resampled/ResizedImage10067-3.jpg" alt="description" onmouseover="show_200('assets/specimages/3.jpg', 'image_3', 418, 280)" onmouseout="hide_div()" /></li>
</ul>

Code it is churning out:

<ul class="hoverbox">
<li><img onmouseover="show_200('assets/specimages/3.jpg', 'image_3', 418, 280)" onmouseout="hide_div()" src="assets/specimages/_resampled/ResizedImage10067-3.jpg" alt="description" /></li>
</ul>

thanks again.

|G|

Avatar
bummzack

Community Member, 904 Posts

14 May 2009 at 5:56pm

That looks ok to me. Seems like the attributes got shuffled a bit, but that doesn't matter.
Doesn't it work like you expected?

Avatar
Lukef

Community Member, 32 Posts

14 May 2009 at 9:11pm

I was testing it locally before testing it on the live site thats all, which is why i wanted to check. but i just applied it to the live site and GUESS WHAT!

IT WORKS!

God is Good to me, he sends able people like yourself to help me out. I hope you have a legendary weekend.

|G|

Avatar
CriaturaCreativaStudio

Community Member, 73 Posts

29 August 2009 at 4:44am

Hi!

Is there a way to prevent the editor making changes into the code?
It's very annoying, all my code is well formed, but all the time inserts some tags that mess up my design!

any help would be much apreciated

Regards

Eduardo