Prevent copy of hidden elements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Spizzat2

    Prevent copy of hidden elements

    I've got a web page with some hidden elements that can be shown
    through various methods. What I'd like is, when the user tries to copy
    the visible stuff on the page, it doesn't copy the hidden stuff in
    between. Is there a simple way to do this? I know I could move the
    whole element using some DOM scripting, but I'd really like to do it
    just using something similar to style.visibilit y=hidden.

    Any suggestions?

    Here's some basic code to tinker with:

    <html>
    <head>
    <script type="text/Javascript">
    var step = 0;
    function test(elem){
    elem = document.getEle mentById(elem);
    if(step == 0){
    elem.style.visi bility = "visible";
    document.getEle mentById("repla ce").innerHTM L = "visibility:vis ible,
    display:'' &nbsp;";
    step = 1;
    }else if(step == 1){
    elem.style.disp lay = "";
    document.getEle mentById("repla ce").innerHTM L = "visibility:hid den;
    display:'' &nbsp;";
    step = 2;
    }else if(step == 2){
    elem.style.visi bility = "hidden";
    document.getEle mentById("repla ce").innerHTM L = "visibility:hid den;
    display:none";
    step = 3;
    }else{
    elem.style.disp lay = "none";
    document.getEle mentById("repla ce").innerHTM L = "visibility:vis ible;
    display:none";
    step = 0;
    }
    }
    </script>

    </head>
    <body>
    Highlight the whole page (Ctrl + A), and paste it into notepad to see
    under which conditions the second row shows up.
    <table border="1">
    <tr><td onclick="test(' dktk')">Click here to make it <span
    id="replace">vi sibility:visibl e, display:none</span></td></tr>
    <tr><td id="dktk" style="display: none; visibility:hidd en;">HHHHHH</
    td></tr>
    <tr><td>There are 2 rows above here</td></tr>
    </body>
    </html>
  • Bart Van der Donck

    #2
    Re: Prevent copy of hidden elements

    Spizzat2 wrote:
    I've got a web page with some hidden elements that can be shown
    through various methods. What I'd like is, when the user tries to copy
    the visible stuff on the page, it doesn't copy the hidden stuff in
    between. Is there a simple way to do this? I know I could move the
    whole element using some DOM scripting, but I'd really like to do it
    just using something similar to style.visibilit y=hidden.
    >
    Any suggestions?
    >
    Here's some basic code to tinker with:
    >
    <html>
    <head>
    <script type="text/Javascript">
    var step = 0;
    function test(elem){
    elem = document.getEle mentById(elem);
    if(step == 0){
    elem.style.visi bility = "visible";
    document.getEle mentById("repla ce").innerHTM L = "visibility:vis ible,
    display:'' &nbsp;";
    step = 1;
    }else if(step == 1){
    elem.style.disp lay = "";
    document.getEle mentById("repla ce").innerHTM L = "visibility:hid den;
    display:'' &nbsp;";
    step = 2;
    }else if(step == 2){
    elem.style.visi bility = "hidden";
    document.getEle mentById("repla ce").innerHTM L = "visibility:hid den;
    display:none";
    step = 3;
    }else{
    elem.style.disp lay = "none";
    document.getEle mentById("repla ce").innerHTM L = "visibility:vis ible;
    display:none";
    step = 0;
    }}
    >
    </script>
    >
    </head>
    <body>
    Highlight the whole page (Ctrl + A), and paste it into notepad to see
    under which conditions the second row shows up.
    <table border="1">
    <tr><td onclick="test(' dktk')">Click here to make it <span
    id="replace">vi sibility:visibl e, display:none</span></td></tr>
    <tr><td id="dktk" style="display: none; visibility:hidd en;">HHHHHH</
    td></tr>
    <tr><td>There are 2 rows above here</td></tr>
    </body>
    </html>
    I believe it's not possible without DOM/innerHTML/etc. techniques (and
    actually I can't think of a good reason why you would be interested in
    this).




    --
    Bart

    Comment

    • Spizzat2

      #3
      Re: Prevent copy of hidden elements

      The reason is that there's a lot of information associated with the
      rows on the page, so I don't want it all displayed all the time, and
      there's a good chance of the user copying/pasting multiple rows into
      an email, and the users don't want all the extra information showing
      up in the email.

      Thanks for the response, though. I figured I'd have to do it the hard
      way if I was going that direction.

      On May 8, 2:40 am, Bart Van der Donck <b...@nijlen.co mwrote:
      Spizzat2 wrote:
      I've got a web page with some hidden elements that can be shown
      through various methods. What I'd like is, when the user tries to copy
      the visible stuff on the page, it doesn't copy the hidden stuff in
      between. Is there a simple way to do this? I know I could move the
      whole element using some DOM scripting, but I'd really like to do it
      just using something similar to style.visibilit y=hidden.
      >
      Any suggestions?
      >
      Here's some basic code to tinker with:
      >
      <html>
      <head>
      <script type="text/Javascript">
      var step = 0;
      function test(elem){
      elem = document.getEle mentById(elem);
      if(step == 0){
      elem.style.visi bility = "visible";
      document.getEle mentById("repla ce").innerHTM L = "visibility:vis ible,
      display:'' &nbsp;";
      step = 1;
      }else if(step == 1){
      elem.style.disp lay = "";
      document.getEle mentById("repla ce").innerHTM L = "visibility:hid den;
      display:'' &nbsp;";
      step = 2;
      }else if(step == 2){
      elem.style.visi bility = "hidden";
      document.getEle mentById("repla ce").innerHTM L = "visibility:hid den;
      display:none";
      step = 3;
      }else{
      elem.style.disp lay = "none";
      document.getEle mentById("repla ce").innerHTM L = "visibility:vis ible;
      display:none";
      step = 0;
      }}
      >
      </script>
      >
      </head>
      <body>
      Highlight the whole page (Ctrl + A), and paste it into notepad to see
      under which conditions the second row shows up.
      <table border="1">
      <tr><td onclick="test(' dktk')">Click here to make it <span
      id="replace">vi sibility:visibl e, display:none</span></td></tr>
      <tr><td id="dktk" style="display: none; visibility:hidd en;">HHHHHH</
      td></tr>
      <tr><td>There are 2 rows above here</td></tr>
      </body>
      </html>
      >
      I believe it's not possible without DOM/innerHTML/etc. techniques (and
      actually I can't think of a good reason why you would be interested in
      this).
      >

      >
      --
      Bart

      Comment

      Working...