htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
Disable JavaScript Cleaner


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.

 


maff
Novice

Jun 4, 2004, 9:43 AM

Post #1 of 16 (5606 views)
Shortcut
Disable JavaScript Cleaner Can't Post

Hi,

I wanna use JavaScipt code in HTMLArea, but everytime the code inside the tag is removed

ie :

...<script language="javascript">alert("foo");</script>

become

...<script language="javascript"></script>




Is there a solution ?

Regards

========================
MAff

h.ferrand@onlineformapro.com
========================
MAff


Evervision
Novice

Jun 4, 2004, 2:57 PM

Post #2 of 16 (5593 views)
Shortcut
Re: [maff] Disable JavaScript Cleaner [In reply to] Can't Post

I had a similar problem with javascript, but in my case it would run the script and error out. I used php to enclose the scripts in html comments. This prevented HTMLArea from removing the script and the browser from running it.


Code
 // Before outputing HTML 
//replace "<script" with "<!--<script" so scripts don't run inside HTMLArea!!
$rawReturnCode = preg_replace("/<script/i","<!--<script",$rawReturnCode);
//replace "</script>" with "</script>-->" so scripts don't run inside HTMLArea!!
$rawReturnCode = preg_replace("/<\/script>/i","</script>-->",$rawReturnCode);
.
.
.
.
.
// After getting HTML to be saved
//replace "<!--<script" with "<script" so scripts run again
$rawReturnCode= preg_replace("/<!--<script/i", "<script", $rawReturnCode);
//replace "</script>-->" with "</script>" so scripts run again
$rawReturnCode= preg_replace("/<\/script>-->/i", "</script>", $rawReturnCode);



Jason


maff
Novice

Jun 10, 2004, 8:32 AM

Post #3 of 16 (5506 views)
Shortcut
Re: [Evervision] Disable JavaScript Cleaner [In reply to] Can't Post

Hi,

Thanks Jason

that is exactly what i was looking for Smile

MAff
MAff


agf
User

Jun 10, 2004, 9:02 AM

Post #4 of 16 (5499 views)
Shortcut
Re: [maff] Disable JavaScript Cleaner [In reply to] Can't Post

What do you do when you enter a new script in a HTMLArea?


Evervision
Novice

Jun 10, 2004, 1:24 PM

Post #5 of 16 (5492 views)
Shortcut
Re: [agf] Disable JavaScript Cleaner [In reply to] Can't Post

As long as the script is in comments, it won't run. When I put new scripts into htmlarea, I just hand enter the comments. You could have a button to create the script tags and comments for you, but I didn't need that.

Good luck

Jason


agf
User

Jun 10, 2004, 1:35 PM

Post #6 of 16 (5489 views)
Shortcut
Re: [Evervision] Disable JavaScript Cleaner [In reply to] Can't Post

I ended up doing the exact same thing you did, but I noticed that if my comments <!--<scriptstart was the first line it would get removed...

I had to insert a dummy table infront of the comment to get it to work :|


maff
Novice

Jun 11, 2004, 2:20 AM

Post #7 of 16 (5475 views)
Shortcut
Re: [agf] Disable JavaScript Cleaner [In reply to] Can't Post

I also noted this problem.
I resolved it by inserting a '&nbsp;' tag before script tag.
MAff


vegetagt
New User

Jun 14, 2004, 1:27 PM

Post #8 of 16 (5431 views)
Shortcut
Re: [maff] Disable JavaScript Cleaner [In reply to] Can't Post


In Reply To
Hi,

I wanna use JavaScipt code in HTMLArea, but everytime the code inside the tag is removed

ie :

...<script language="javascript">alert("foo");</script>

become

...<script language="javascript"></script>




Is there a solution ?

Regards

========================
MAff

h.ferrand@onlineformapro.com
========================

i have same problem.. an solution?


(This post was edited by vegetagt on Jun 14, 2004, 1:51 PM)


maff
Novice

Jun 15, 2004, 7:41 AM

Post #9 of 16 (5405 views)
Shortcut
Re: [vegetagt] Disable JavaScript Cleaner [In reply to] Can't Post

Hi, The solution is to surround tag "<script></script>" with HTML comment "<!--<script></script>-->".
Pay attention , if the script is at the top of your page, you must whrite something else before (ie: &nbsp; or a table,...)
For my part I use a "<img .../>" in order to visualize when editor is in wysiwig mode.

So when editor is in HTML mode, write :
&nbsp;<!--<script language="javascript">alert("foo");</script> -->

When you submit your FORM, on the server side, remove the HTML comment, in order your script be excute when display. ie in ASP/VBScript :
foo = Replace(foo ,"<!--<script","<script")
foo = Replace(foo ,"</script>-->","</script>")
or in PHP :
$foo = preg_replace("/<!--<script/i", "<script", $foo);
$foo = preg_replace("/<\/script>-->/i", "</script>", $foo);

When you need to edit your page, do the reverse by adding HTML comment : ie in ASP/VBscript :
foo = Replace(foo ,"<script","<!--<script")
foo = Replace(foo ,"</script>","</script>-->")
in PHP :
$foo = preg_replace("/<script/i", "<!--<script", $foo);
$foo = preg_replace("/<\/script>/i", "</script>-->", $foo);

Hope it will help you. @+ MAff


in french

salut,

La solution c'est d'encadrer les balises "<script></script>" par des commentaires html "<!--<script></script>-->". Attention si le script et la première chose que tu insere dans ta page met un espace insecable "&nbsp;" ou un tableau (ou ce que tu veux) sinon ton script disparait. (Moi j'englobe le script commenté entre 2 images ce qui me permet de le materialiser en Wysiming)


Donc lorsque tu es sur l'editeur en mode html tu encadre ton script par des commentaires
Exemple :


&nbsp;<!--<script language="javascript">alert("foo");</script> -->


A l'enregistrement(Sortie de l'éditeur) de ta page du devra enlever les commentaire pour que ton script puisse s'éxécuter :
Exemple en ASP :


texte = Replace(texte ,"<!--<script","<script")
texte = Replace(texte ,"</script>-->","</script>")


Exemple PHP :


$texte = preg_replace("/<!--<script/i", "<script", $texte);
$texte = preg_replace("/<\/script>-->/i", "</script>", $texte);


A l'ouverture d'une page (Entrée éditeur) tu fait l'inverse en ajoutant les commentaires :

Exemple en ASP :


texte = Replace(texte ,"<script","<!--<script")
texte = Replace(texte ,"</script>","</script>-->")


Exemple PHP :


$texte = preg_replace("/<script/i", "<!--<script", $texte);
$texte = preg_replace("/<\/script>/i", "</script>-->", $texte);


J'espère t'avoir renseigné.

@+
MAff

(This post was edited by maff on Jun 16, 2004, 7:01 AM)


vegetagt
New User

Jun 15, 2004, 11:26 AM

Post #10 of 16 (5395 views)
Shortcut
Re: [maff] Disable JavaScript Cleaner [In reply to] Can't Post

i use this script for popup:

<script language="javascript" type="text/javascript">
function ApriImmagini(file)
{
var prop = "top=100, left=100";
window.open(file, null, prop);
}
</script>

now if i write:

&nbsp;<!--<script language="javascript" type="text/javascript">
function ApriImmagini(file)
{
var prop = "top=100, left=100";
window.open(file, null, prop);
}
</script>-->

the script dosnt work :\


maff
Novice

Jun 16, 2004, 7:13 AM

Post #11 of 16 (5368 views)
Shortcut
Re: [vegetagt] Disable JavaScript Cleaner [In reply to] Can't Post

In order your script be excute when display, when you submit your FORM, on the server side, remove the HTML comment, . ie in ASP/VBScript :
foo = Replace(foo ,"<!--<script","<script")
foo = Replace(foo ,"</script>-->","</script>")
or in PHP :


$foo = preg_replace("/<!--<script/i", "<script", $foo);
$foo = preg_replace("/<\/script>-->/i", "</script>", $foo);


and result for your script =


<script language="javascript" type="text/javascript">
function ApriImmagini(file)
{
var prop = "top=100, left=100";
window.open(file, null, prop);
}
</script>

MAff


agf
User

Jun 18, 2004, 9:41 AM

Post #12 of 16 (5309 views)
Shortcut
Re: [maff] Disable JavaScript Cleaner [In reply to] Can't Post

So, all you're doing is dropping in a &nbsp; in front of your <!--<scipt> ???

That's what I just tried ... it works alright if it is ANYWHERE other than the first line of the HTML.

Any ideas?

I'm currently using a table to get around this, but there is a chance the user could delete the table...


maff
Novice

Jun 18, 2004, 10:08 AM

Post #13 of 16 (5304 views)
Shortcut
Re: [agf] Disable JavaScript Cleaner [In reply to] Can't Post

this tips &nbsp; in front of your <!--<scipt> is made for the case script on first line.

Show us your code .
MAff


agf
User

Jun 18, 2004, 10:17 AM

Post #14 of 16 (5302 views)
Shortcut
Re: [maff] Disable JavaScript Cleaner [In reply to] Can't Post

Pardon the typo, but yah..that's what I said... but I meant <!--<script

I do not think my code is the problem as it inserts the &nbsp; just fine


Code
 
// String longstring = "<img id=\"scriptblock\" src=\"images/script_img.gif\" border=\"0\" />";

if(edT != null && !edT.equals("")){
edT = edT.replaceAll("<script","&nbsp;<!--<script ");
edT = edT.replaceAll("<SCRIPT","&nbsp;<!--<script ");
edT = edT.replaceAll("<Script","&nbsp;<!--<script ");
edT = edT.replaceAll("</script>"," script-->");
edT = edT.replaceAll("</SCRIPT>"," script-->");
edT = edT.replaceAll("</Script>"," script-->");


The form processing basically reverses the above code.

It would work fine with a dummy table, and it looks like it works fine with an image in front... really which is not a bad idea to let the user know that there is a script below...


mharrisonline
Novice

Jan 8, 2005, 3:42 AM

Post #15 of 16 (4641 views)
Shortcut
Re: [agf] Disable JavaScript Cleaner [In reply to] Can't Post

I've read that htmlArea does this because the javascript would launch within htmlArea and cause problems. I have found that without modification I can paste javascript into another mozilla editor (http://www.fckeditor.net/demo/default.html) without any problems, or code being removed.

However, I have found that if I am using the full page plugin and my javascript tags are in the <head> area, the javascript is not stripped out. So, I guess you could make everything that would need to work in the body a function that could be called by an event...


(This post was edited by mharrisonline on Jan 8, 2005, 4:03 AM)


mharrisonline
Novice

Jan 10, 2005, 1:13 AM

Post #16 of 16 (4615 views)
Shortcut
Re: [mharrisonline] Disable JavaScript Cleaner [In reply to] Can't Post

I found that I can stop htmlArea from cleaning out javascript tags in Mozilla, just find the line:


Code
  // if true then HTMLArea will retrieve the full HTML, starting with the 
// <HTML> tag.
this.fullPage = false;



And change false to true!


Code
  // if true then HTMLArea will retrieve the full HTML, starting with the 
// <HTML> tag.
this.fullPage = true;



And then htmlArea not only leaves the head alone without having to use the Full Page plugin, it also leaves javascript alone! Unfortunately it doesn't stop IE from removing the Javascript.


(This post was edited by mharrisonline on Jan 16, 2005, 3:08 PM)

 
 
 


Search for (options)