Enhance your code with TinyMCE scripting

Currently, I am exploring methods to incorporate an external script into tinymce. The specific script in question is p7EHCscript which is designed to ensure two divs have equal heights based on the larger div's height.

I aim to integrate the p7EHC script within the tinymce editor so that it mirrors the appearance of the final page being developed.

The current configuration with tinymce includes:

tinyMCE.init({

            // General options
            mode : "textareas",
            editor_selector : "mceEditor",
            editor_deselector : "mceNoEditor",
            remove_script_host : false,
            convert_urls : false,
            content_css : 'http://localhost/tmtphotography/css/mce.css',

            width: "1030",
            height : "480",

            theme : "advanced",
            plugins : "safari, pagebreak, style, layer, table, save, advhr, advimage, advlink, emotions, iespell, inlinepopups, insertdatetime, preview, media, searchreplace, print, contextmenu, paste, directionality, fullscreen, noneditable, visualchars, nonbreaking, xhtmlxtras, template,preview",
            file_browser_callback : "filebrowser",
            // Theme options
            theme_advanced_buttons1 : "save,preview,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage,imgae,media,link",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing : true,

             theme_advanced_font_sizes : "10px,12px,13px,14px,16px,24px",
     font_size_style_values : "xx-small,x-small,12pt,medium,large,x-large,xx-large",


            // Skin options
            skin : "o2k7",
            // Example content CSS (should be your site CSS)


    });
  `

Your assistance in guiding me through this process would be greatly valued.

Answer №1

If you're looking to include the script in the document head using a script tag, here's how you can do it:

<script type="text/javascript" src="javascript/p7EHCscripts.js"></script>

Since tinymce utilizes its own iframe with its own document, we need to target this specific iframe. Here is the code required to achieve this:

var iframe_id = 'your_editor_id' + '_ifr'; // replace 'your_editor_id' with your editor id+'_ifr'
with(document.getElementById(iframe_id).contentWindow) {
  
  var h = document.getElementsByTagName("head");
  if (!h.length) return;
  var scripttag = document.createElement("script");
  scripttag.type = "text/javascript";
  scripttag.src = "http://myserver.com/my_dir1/my_dir2/javascript/p7EHCscripts.js"; // example
  h[0].appendChild ( scripttag );
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring Database with NodeJS, Express, and HTML

My goal is to create a basic web application using node.js where users can input data into a search bar and have that input sent to the server for database query. While I've successfully set up and connected my database, here's a glimpse of my co ...

Jssor's dynamic slider brings a touch of sophistication to preview upcoming images

Incorporating the jssor nearby slider to create a nearly fullscreen display. The goal is to set the opacity of upcoming images to 0.25 when they are not in the main viewport, giving the edges of the upcoming and previous slides a slight transparency. < ...

Glitchy/Crazy CSS3 Animations

Currently, I am developing a website at . One of the features I have implemented is CSS3 transitions for route changes, but this feature only works in Chrome. Here's how the animation works: I apply the .preanimate class to rotate the phasing out di ...

Can JavaScript be used to mimic selecting a location from the autocomplete dropdown in Google Maps API 3?

Currently, I am attempting to automate the process of selecting items from the autocomplete dropdown in the Google Maps API v3 places library using jQuery. However, I am facing difficulty in identifying the necessary javascript code to select an item from ...

Is the process of converting text to PNG and then reading it as a stream all completed on the front-end?

Is it feasible to achieve the following task? Allow the user to input text Generate a PNG from the entered text Upload the PNG to Pinata, in ReadStream format Perform all of these actions on the front-end Steps (1) and (2) have been successfully complete ...

Efficiency boost: Implementing ajax to load content

Let's discuss the best methods for optimizing content loading with ajax. I will outline a few techniques and provide my insights on each one. Loading html directly - This method makes it easy to load content without much additional processing requir ...

Design a dynamic pagination button for my project that allows users to navigate between pages effortlessly

Can anyone assist me in creating next and previous buttons? I've been struggling with my JavaScript skills. I noticed that many people use jQuery or pure JavaScript for this. Since I'm still learning JavaScript, there are a lot of concepts I&apos ...

Is it possible to remove the "getContext" property from the HTML5 Canvas element using a script?

Visit the HTML5 conformance test suite to find a test for the prototype of HTMLCanvasElement. While this test fails for Safari and Firefox, it passes for Opera on Windows 7. The script within the test attempts to delete the getContext property of HTMLCan ...

What is the best way to trigger a random quote to load from an API in ReactJS using an event like onLoad or another method?

I am currently working on developing a random quote generator. Below is the code I have written so far: import React from "react"; import "./App.css"; function App() { const [quote, setQuote] = React.useState({ text: "" ...

switching back and forth between the registration and login forms

<script> $(document).ready(function(){ $("#register_link").click(function() { $("#login_or_register").empty(); $("#login_or_register").load("register_form.php"); }); $("#login_link").click(function() { $("# ...

transferring information within React applications

I created a basic online store and I am looking to transfer data from one JavaScript file to another. The first JS file displays the items, and then I want to pass the item data to cart.js which contains a table. <section className="products"> ...

Prevent the Stop Function from being executed repeatedly while scrolling

I have implemented infinite scrolling in my react/redux app. As the user nears the bottom of the page, more contents are loaded dynamically. However, a challenge arises when the user scrolls too fast and triggers the function responsible for fetching cont ...

Tips for retrieving data from a JSON response with the specified structure

When I make a request, the response is as follows: { "data": [ "http:\/\/www.domain.com.br\/anunciantes\/jorgediaz.y.com.r\/26\/img1.jpg", "http:\/\/www.domain.com.br\/anunciantes\/jorg ...

Cross domain request in a simple HTML document

I'm currently working on an app that is strictly in plain HTML files without a server. I'm facing difficulties with cross domain requests from JavaScript. Whenever I try to make a request, the browser displays this error message: XMLHttpRequest ...

Having trouble importing Bootstrap into Next.js? It seems like the issue may be related to the

I am currently facing an issue with importing bootstrap 5.3.2 (not react-bootstrap) into my NextJS 14.1.0 project that utilizes the new App Router. My goal is to strategically utilize individual Bootstrap components (not through data-attrs). I managed to ...

automatically created button, form control named 'answer' that is not valid

Struggling with a challenge in attaching an event to a dynamically generated button. Despite conducting some research, most of the solutions suggest that this issue is typically related to a form control. However, in my scenario, the error "invalid form co ...

Could anybody provide some assistance with JavaScript?

<div id="toggler" class="toggler"> <div id="toggler" class="line1"></div> <div id="toggler" class="line2"></div> <div id="toggler" class=& ...

Issue with highcharts and vue.js: creating a unique chart for displaying measurements

Currently, I am integrating Highcharts and Vue.js simultaneously while incorporating multiple charts on my webpage. As of now, I have successfully displayed data on all the charts without encountering any issues. However, my goal is to assign a special tit ...

Vue.js is throwing an error because it cannot find the property or method "blah" when referencing it during rendering

Can you explain why Vue 2 throws an error indicating that a prop is not defined, even though it is statically defined in the parent template? Note: This error does not occur when I include the JavaScript code within the .vue file's script tag instead ...

Navigate to items within a content block with a set height

I have a <div> that has a fixed height and overflow-y: scroll. Inside this div, there is mostly a <p> tag containing a long text with some highlighting (spans with background-color and a numbered id attribute). Just to note, this is an HTML5 a ...