Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2006-09-12 02:48:33

rockstar33
New member
Registered: 2006-08-10
Posts: 9

Acessing the Xinha Iframe

Hi,

Is it possible to access the Iframe that Xinha uses to display the WYSIWYG interface using javascript.

What I am trying to do is to use DOM to remove certain attributes (that dont follow a pattern), and also certain tags in their entirety before submitting the content of the editor. I thought using document.frames.("coontent").document.getElementsByTagName might allow me access the elements in the Iframe. I have given the IFrame a name in htmlArea.js.

Any help much appreciated!

Conor

Offline

#2 2006-09-12 20:13:34

rockstar33
New member
Registered: 2006-08-10
Posts: 9

Re: Acessing the Xinha Iframe

Or eve If I can just access the submitted content as a string with javascript it would be ok. Where is the content stored, is it within a textarea or an iframe? How can I access it before the page is submitted?

Thanks,
Conor

Offline

#3 2006-09-13 05:34:16

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Acessing the Xinha Iframe

iframe is at: xinha_editors.yourEditor._iframe
content can be got from: xinha_editors.yourEditor.getHTML()


James Sleeman

Offline

#4 2007-05-03 14:08:24

rockstar33
New member
Registered: 2006-08-10
Posts: 9

Re: Acessing the Xinha Iframe

I now need to pass a value to another javascript function with the name of the editor.

function encodeXinha(editorID) {
    xinha_editors.editorID.setHTML(escape(xinha_editors.editorID.getHTML()));
    return true;
}

This however give me an error. The following works, even though editorID in the first example is a string containing "Editor1".

function encodeXinha(editorID) {
    xinha_editors.Editor1.setHTML(escape(xinha_editors.Editor1.getHTML()));
    return true;
}

How can I pass the name of the Editor as a variable to the function and then access its setHTML and getHTML methods?

Thanks,
Conor

Offline

#5 2007-05-03 18:22:09

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Acessing the Xinha Iframe

1. You cannot use the dot syntax to access object properties by a variable; instead use the following syntax

xinha_editors[editorID]

2. You should not use getHTML()/setHTML directly, but rather

xinha_editors.yourEditor.setHTML(xinha_editors.yourEditor.inwardHtml(html))
xinha_editors.yourEditor.outwardHtml(xinha_editors.yourEditor.getHTML())

or as of realease 0.93, for convenience

var html = xinha_editors.yourEditor.getEditorContent();
xinha_editors.yourEditor.setEditorContent(html);

(this is the same as above, integrated in one function)

3. Why on earth do you want to escape the content??

Offline

#6 2007-05-03 18:30:12

rockstar33
New member
Registered: 2006-08-10
Posts: 9

Re: Acessing the Xinha Iframe

:-) Well dot net is giving me errors when submitting anything with tags, because of its built in security features. So im escaping the data on the way out and doing the opposite on the way back in.

Offline

#7 2007-05-03 19:36:16

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Acessing the Xinha Iframe

evil wink

Offline

#8 2007-05-03 19:38:07

rockstar33
New member
Registered: 2006-08-10
Posts: 9

Re: Acessing the Xinha Iframe

this is just the begining. i plan to be an overlord some day.

Offline

#9 2007-05-06 06:03:09

MyLocalFOCUS.com
Xinha Community Member
Registered: 2007-02-17
Posts: 31

Re: Acessing the Xinha Iframe

Escaping stuff on the way out and in is asking for trouble really.

You can turn off the .NET security feature that is doing this at the page level. (I wish that there was a code-behind option, but there isn't).

In your @Page directive of your .aspx, you just add validateRequest="false"

This will allow html tags to be submitted, so is slightly less secure. It saves you having to escape everything. However, if you still do escape everything and it works ok, perhaps you could share it with xinha community.

Offline

#10 2007-05-07 11:07:20

rockstar33
New member
Registered: 2006-08-10
Posts: 9

Re: Acessing the Xinha Iframe

Hi,

Well this is what im doing so far. On Page_load I decode the server tag containing the xinha textarea :
   
protected void decodeXinha()
    {
        Job_Overview.Text = HttpUtility.UrlDecode(Job_Overview.Text);
    }

and the form button that submits the form, I add another onclick attribute :

//Create Client Javascript Call on Form Submit
        editCategorySubmit.Attributes.Add("OnClick", "javascript:encodeXinha('" + Job_Overview.ClientID + "');");

By using the ClientId property of my Xinha Textarea it ensures that the correct id is sent to the client side javascript, regardless of whether the textarea is in a control, or part of a .net wizard.

Finally in my javascript I have simple functions :

function encodeXinha(editorID) {
xinha_editors[editorID].setHTML(escape(xinha_editors[editorID].getHTML()));
}

This last bit is the bit I was having trouble with.

Offline

#11 2007-05-09 10:15:28

MyLocalFOCUS.com
Xinha Community Member
Registered: 2007-02-17
Posts: 31

Re: Acessing the Xinha Iframe

I am not quite sure what you are trying to acheive.

Why are you URLDecoding stuff for the text area? URL Decode is designed to decode the values in the querystring, such as %20 back to a space etc.


I am not doing anything special in my form...

Goto the HTML source of your .ASPX page. Your should have an @Page directive at the top. In that line, put validateRequest="false"

That will allow "potentially unsafe" content to pass through on a form post. It is a nuisance, but it is the only way it will work.

When loading the content into the editor...
Job_Overview.Text = {your text that you want to put in it};

When receiving the text back into your code, in your form submit function (button onclick)...
{wherever you want to save your data} = Job_Overview.Text;

Simple as that. You just treat the Xinha text area just like any other .NET textarea. The only thing is being able to pass the "potentially unsafe" content.

Hope this helps.

Offline

#12 2007-05-09 10:24:56

rockstar33
New member
Registered: 2006-08-10
Posts: 9

Re: Acessing the Xinha Iframe

What im trying to do is to allow .NET validate all the other tags on the page. I knw what url decode is for, Im using it because in this case it allows me achieve submiting the form, validating the controls, and using Xinha.

I understand thats not why URLDecode is there, but am I opening myself to problems by doing this?

Offline

#13 2007-05-09 17:42:40

MyLocalFOCUS.com
Xinha Community Member
Registered: 2007-02-17
Posts: 31

Re: Acessing the Xinha Iframe

Hi,

I am not sure what you are trying to achieve...

For the URLDecode, I don't actually know if it will cause any problems. I will guess that it doesn't, but I don't think it will trap all potential encoded HTML issues either.

As to validating all the other controls, can't you just use the validation controls? Do you need to validate the xinha area? If so, then you might need to write custom validation. If not, then you just don't include it in the validation.

If you want to discuss off board to try and get you a solution, send me an email.   xinha at revilloc dot com

Offline

Board footer

Powered by FluxBB