Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3455450
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:36:58+00:00 2026-05-18T09:36:58+00:00

I am making a small HTML page editor. The editor loads a file into

  • 0

I am making a small HTML page editor. The editor loads a file into an iframe. From there, it could add, modify, or delete the elements on the page with new attributes, styles, etc. The problem with this, is that JavaScript (and/or other programming languages) can completely modify the page when it loads, before you start editing the elements. So when you save, it won’t save the original markup, but the modified page + your changes.

So, I need some way to disable the JavaScript on the iframe, or somehow remove all the JavaScript before the JavaScript starts modifying the page. (I figure I’ll have to end up parsing the file for PHP, but that shouldn’t be too hard) I considered writing a script to loop through all the elements, removing any tags, onclick’s, onfocus’s, onmouseover’s, etc. But that would be a real pain.

Does anyone know of an easier way to get rid of JavaScript from running inside an iframe?

UPDATE: unless I’ve missed something, I believe there is no way to simply ‘disable JavaScript.’ Please correct me if I’m wrong. But, I guess the only way to do it would be to parse out any script tags and JavaScript events (click, mouseover, etc) from a requested page string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:36:59+00:00Added an answer on May 18, 2026 at 9:36 am

    You can try the same solution adopted by CKEditor, of which you have a demo here.
    By switching from RTE mode to view source mode, you can enter some JavaScript and see the result, which is a replacement of the JS node in a safely encoded string.
    If you are in view source mode, by entering some JS line like:

    <script type="text/javascript">
    // comment
    alert('Ciao');
    </script>
    

    you will see it rendered this way when going back to rich text editor mode:

    <!--{cke_protected}%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0D%0A%2F%2F%20comment%0D%0Aalert('Ciao')%3B%0D%0A%3C%2Fscript%3E-->
    

    I think it is one of the easiest and effective way, since the RegExp to parse JS nodes is not complex.
    An example:

    var pattern = /<script(\s+(\w+\s*=\s*("|').*?\3)\s*)*\s*(\/>|>.*?<\/script\s*>)/;
    var match = HTMLString.match(pattern); // array containing the occurrences found
    

    (Of course, to replace the script node you should use the replace() method).

    Regards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making small module/plugin for my future CMS/Framework. I wanted it from begining to
I'm making a small Adobe AIR app (my first) using HTML+Javascript. I need to
I was making a small thing in HTML and basically I have some frames
Im making a small python script to upload files on the net. The script
I'm making a small web application in Seaside. I have a login component, and
I'm making a small quiz-application in Flash (and ActionScript 3). Decided to use the
I was thinking of making a small tool. It is not important what the
I am making a small website as my first project. I have finalized to
I'm making a small project in Google AppEngine but I'm having problems with international
im making a small site And Instead of having a header.php and a footer.php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.