Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Prevent copy of hidden elements

Reply
Thread Tools

Prevent copy of hidden elements

 
 
Spizzat2
Guest
Posts: n/a
 
      05-07-2008
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.visibility=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.getElementById(elem);
if(step == 0){
elem.style.visibility = "visible";
document.getElementById("replace").innerHTML = "visibility:visible,
display:'' &nbsp;";
step = 1;
}else if(step == 1){
elem.style.display = "";
document.getElementById("replace").innerHTML = "visibility:hidden;
display:'' &nbsp;";
step = 2;
}else if(step == 2){
elem.style.visibility = "hidden";
document.getElementById("replace").innerHTML = "visibility:hidden;
display:none";
step = 3;
}else{
elem.style.display = "none";
document.getElementById("replace").innerHTML = "visibility:visible;
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">visibility:visible, display:none</span></td></tr>
<tr><td id="dktk" style="display:none; visibility:hidden;">HHHHHH</
td></tr>
<tr><td>There are 2 rows above here</td></tr>
</body>
</html>
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      05-08-2008
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.visibility=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.getElementById(elem);
> if(step == 0){
> elem.style.visibility = "visible";
> document.getElementById("replace").innerHTML = "visibility:visible,
> display:'' &nbsp;";
> step = 1;
> }else if(step == 1){
> elem.style.display = "";
> document.getElementById("replace").innerHTML = "visibility:hidden;
> display:'' &nbsp;";
> step = 2;
> }else if(step == 2){
> elem.style.visibility = "hidden";
> document.getElementById("replace").innerHTML = "visibility:hidden;
> display:none";
> step = 3;
> }else{
> elem.style.display = "none";
> document.getElementById("replace").innerHTML = "visibility:visible;
> 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">visibility:visible, display:none</span></td></tr>
> <tr><td id="dktk" style="display:none; visibility:hidden;">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).

http://www.w3schools.com/css/pr_class_display.asp
http://www.w3schools.com/CSS/pr_class_visibility.asp

--
Bart
 
Reply With Quote
 
 
 
 
Spizzat2
Guest
Posts: n/a
 
      05-08-2008
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 <(E-Mail Removed)> wrote:
> 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.visibility=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.getElementById(elem);
> > if(step == 0){
> > elem.style.visibility = "visible";
> > document.getElementById("replace").innerHTML = "visibility:visible,
> > display:'' &nbsp;";
> > step = 1;
> > }else if(step == 1){
> > elem.style.display = "";
> > document.getElementById("replace").innerHTML = "visibility:hidden;
> > display:'' &nbsp;";
> > step = 2;
> > }else if(step == 2){
> > elem.style.visibility = "hidden";
> > document.getElementById("replace").innerHTML = "visibility:hidden;
> > display:none";
> > step = 3;
> > }else{
> > elem.style.display = "none";
> > document.getElementById("replace").innerHTML = "visibility:visible;
> > 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">visibility:visible, display:none</span></td></tr>
> > <tr><td id="dktk" style="display:none; visibility:hidden;">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).
>
> http://www.w3schools.com/css/pr_clas...visibility.asp
>
> --
> Bart


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Win 7 folders hidden despite 'show hidden' checked Boppy NZ Computing 10 01-23-2010 02:56 AM
How can I prevent selecting and dragging with overflow: hidden ? amypower@gmail.com HTML 3 10-02-2006 08:11 PM
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
is dict.copy() a deep copy or a shallow copy Alex Python 2 09-05-2005 07:01 AM



Advertisments