'TinyMCE deletes some <a> tags. Settings ignored
I've been trying to force TinyMCE to not delete my a tags with every setting that is available and have had no luck (also looked at 20+ posts here - most being over a decade old and no working solutions). I'm just going to post what I try to put into the editor and what it removes (along with every setting I've tried).
What the markup should look like:
<a href="#" class="hearmorelink" onclick="window.open('/Mini-Lots-audio.html', 'Voice Over', 'width=320,height=1,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no');return false;">
<div>Want to hear more?<span style="margin-top: 60px;">CLICK HERE</span></div>
</a>
what tinyMCE does to it:
<div>Want to hear more?<span style="margin-top: 60px;">CLICK HERE</span></div>
Maybe not the prettiest HTML ever, but why does it disallow wrapping anything inside an A tag when it's perfectly acceptable HTML5 as per the RFC?
apply_source_formatting: false,
verify_html: false,
trim_span_elements: false,
cleanup: false,
convert_urls: false,
cleanup_on_startup: false,
force_br_newlines: true,
force_p_newlines: false,
allow_script_urls: true,
forced_root_block: false,
valid_elements: '+*[*]',
plugins: [
"advlist autolink autoresize directionality lists link image charmap preview anchor",
"searchreplace visualblocks code fullscreen textcolor",
"insertdatetime media table contextmenu paste"
],
All the settings seem to be working, but this problem still persists. Because this is needed for 50 or so pages and the HTML is stored and retrieved from a database, I can't hard-code anything in (also - non-HTML people/admins need to use this too).
I am not sure how I can make this work (and, yes, it MUST be a popup so the audio can play while people visit from page to page). Would a plugin help here?
Solution 1:[1]
okay - after doing a few more tweaks, I've found that TinyMCE is stuck in HTML4 (which does not allow block elements inside A tags). HTML5 supports DIV tags inside A tags. I'll just change the markup and tweak the span tag to display like a block with CSS.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MC9000 |