Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Posts posted by Ingolme

  1. It is impossible to protect HTML code, but I will do what you asked.

    Here is the above code without password:

    <div id="thecode" style="display:none">
    &lt;noscript&gt;JavaScript must be enabled in your browse in order to see protected page.&lt;/noscript&gt;
      function do_encode() {
        orig = document.getElementById("as1").value;
        thecode1 = document.getElementById("thecode").innerHTML;
        thecode1 = thecode1.replace(/&lt;/g,'<');
        thecode1 = thecode1.replace(/&gt;/g,'>');
        thecode1 = thecode1.replace(/&amp;/g,'&');
        orig1 = thecode1.replace(/thecode/,escape(orig));
        document.getElementById("as2").value = orig1;
      <b>Enter your HTML code to be encrypted:<br></b>
      <textarea id="as1" rows="10" cols="50"></textarea><br>
      <button onclick="do_encode()">Click Here to Encrypt and Password Protect Your HTML</button><br>
      This is your protected HTML page text. Save this text as an HTML file:<br>
      <textarea id="as2" rows="10" cols="50"></textarea>


    • Thanks 1
  2. Actually, to remove the password from the generated HTML, just cut out everything and only keep these lines:

    <script language="JavaScript1.2">
    orig = unescape( /* ... ... ... ... */ );
    orig1 = orig1.replace(/mmm/g,"\r\n");
    <noscript>JavaScript must be enabled in your browse in order to see protected page.</noscript>


    • Thanks 1
  3. orig_pass = prompt("Please enter password","");

    To remove the password prompt, just replace the above line with whichever fixed value you want.

    orig_pass = "XYZ";


    This code is not very good, the variables aren't properly declared and they're using outdated attributes. If you're intending to hide your source code from people, I will have to warn you that it is impossible. If the browser is able to read the source code then so can anybody.

    • Thanks 1
  4. The position property in CSS determines how the top, right, bottom and left properties behave. When set to "relative", the element gets moved a certain distance from where it started, but the space it was in remains reserved. If the position is set to "absolute" then the element will be positioned from the edges of its nearest positioned container.

    It's best if you try out the examples in the tutorial page: https://www.w3schools.com/css/css_positioning.asp

  5. For front end development you should learn HTML, CSS and Javascript.

    If you want to be purely a designer, you don't necessarily need to learn the languages but it helps to know them. I've worked with some designers in the past, they pass their design documents to the developers, so they don't need to write code.

  6. First, get all <p> elements.

    var elements = document.getElementsByTagName("p");

    Then, loop through all of them. This has to be done in reverse order because deleting items reindexes the elements node list we obtained. (If you want to learn more about this I can explain it in more detail)

    var element;
    for(var i = elements.length-1; i >= 0; i--) {
      element = elements[i];

    For each element in the loop, check its contents. This is the complicated part. You have to remove all <br> elements and whitespace from the element's innerHTML and check whether the result is empty. If it was just normal whitespace, the trim() method would be enough, but you wanted to check for <br> and &nbsp; so we need a regular expression.

    var contents = element.innerHTML;
    contents = contents.replace(/(<br[^>]>|&nbsp;|\s|\n|\r|\t)+/gi, "");
    if(contents.length === 0) {


  7. A database is not required but recommended. You could just write the data into files on the server's filesystem. The most commonly used databases use SQL, but there are alternatives. Anyway, it would be good to learn SQL.

  8. I recommend doing the tutorials in the order HTML > CSS > Javascript.

    If there's something you don't understand you can always come back to review it later. This kind of knowledge builds up gradually over time.

    • Thanks 1
  9. You don't seem to have a full grasp on how Javascript works, I recommend spending more time studying the Javascript tutorial.

    The second example is more correct, but you're making things confusing by assigning two completely different things to the same variable. "iframe" is a variable and you could name it anything you want and assign any value to it. I would recommend, to prevent things from being confusing, that you only assign an actual iframe object to it and not anything else like "outerHTML" which is just a string.

    The actual reason that the second block of code is not working is that HTML <iframe> elements don't have a "document" property. You can see the list of properties that the iframe has in this reference page: https://www.w3schools.com/jsref/dom_obj_frame.asp

    Using the reference page shown above to determine which iframe property will solve your problem.

  10. If you see any mistakes on a W3Schools page anywhere on the site, you can click the "REPORT ERROR" link at the bottom of the page. The website staff are not active on the forums.

  11. The first statement is correct. The following code outputs "ld!"

      var str = "Hello world!";
      var res = str.substr(-3);

    The other statement should be revised to "If start is negative and larger than the length of the string, start is set to 0"

    The fastest way to report errors to the W3Schools staff is to click the "REPORT ERROR" button at the bottom of every page, since they don't actively participate in the forums.

  • Create New...