htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0:
how to call functions from custom popup


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


mrjameswells
New User

Jan 23, 2005, 8:34 AM

Post #1 of 5 (2177 views)
Shortcut
how to call functions from custom popup Can't Post

Is there an easy way to call one of the htmlarea's function from a custom pop up window?

For example in my pop up window I just want to call this function:

editor_insertHTML('myBody','Hello World');


theauthor
Novice

Jan 25, 2005, 10:13 AM

Post #2 of 5 (2113 views)
Shortcut
Re: [mrjameswells] how to call functions from custom popup [In reply to] Can't Post

From within the popup the following script will do what you want:

<script>
window.opener.editor_insertHTML('Body','Hello World');
</script>

Of course you can place that in an event handler or <a> tag as needed.


mrjameswells
New User

Jan 27, 2005, 9:29 AM

Post #3 of 5 (2096 views)
Shortcut
Re: [theauthor] how to call functions from custom popup [In reply to] Can't Post

when I do that I get a error something like this

window.opener is null or not an object


theauthor
Novice

Jan 27, 2005, 9:46 AM

Post #4 of 5 (2093 views)
Shortcut
Re: [mrjameswells] how to call functions from custom popup [In reply to] Can't Post

Ah! You are using an actual "popup" window. The solution is DON'T. Use a regular window, then window.opener will work. There is intentionally (for security reasons) no way to acces the parent (or to do just about anything else at all) from within the popup.


Luis
Veteran

Jan 28, 2005, 11:40 PM

Post #5 of 5 (2070 views)
Shortcut
Re: [mrjameswells] how to call functions from custom popup [In reply to] Can't Post

Hi mrjameswells:

The hard part when using window.open is to pass the name of the editor object to the popup window. One way is setting a global variable in editor.js which could be hard to explain, then let's try a simpler hack, adding the object name to the popup url in the form of an anchor tag. The name of the property is called hash. This will do the trick.

else if (cmdID.toLowerCase() == 'custom'){
var newWindow;
var props = 'scrollBars=yes,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=360,height=190,top=180,left=200';
newWindow = window.open('popups/custom.html#'+objname,' ', props);
}


Now, in your custom.html page (or whatever you call it):

var parent_objname = location.hash.substring(1,location.hash.length);

function returnString() {
var opener = top.parent.opener;
var text = "the string you want to return to the editor";

window.returnValue = opener.editor_insertHTML(parent_objname,text); // set return value
window.close(); // close dialog
}


Of course, you need to asign the returnString() function to the object and the event you use in the popup page to insert the text (button, link, onunload, etc)

Greetings.


Don't give up!!
http://webstationone.com/test/htmlarea


(This post was edited by Luis on Jan 28, 2005, 11:43 PM)

 
 
 


Search for (options)