473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.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>
Jun 27 '08 #1
2 2342
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
Jun 27 '08 #2
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.comwrote:
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
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
7
by: PJ | last post by:
I have two img elements in a div tag, the first set up w/ float:left and the second set up w/ float:right. When the browser's window width is less than the total width of the two images second img...
2
by: Liming | last post by:
hello, I have the follwoing code <div id="detailtable" style="visibility:hidden"> <table id="detailtablehidden" width="100%" border="0"> .... </table> </div>
2
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.