You are not logged in.
Pages: 1
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
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
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
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
:-) 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
this is just the begining. i plan to be an overlord some day.
Offline
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
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
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
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
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
Pages: 1