By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

Prevent Stop Block certain HTML Tag from being Copied e.g. URL <a> tag

P: 1
i want to make it so that when a user copies an image from a website and pastes this image in, say, their email client, the <a> tag URL which surrounds the image tag is not copied along with the image.

This was brought to my attention by a colleague who copied images from the website into Outlook which retained the URL somehow. As she did not want the URL to be sent to the recipient, only the image. I told her she could simply right click -> remove hyperlink but she didn't want to have to do this, And one could easily forget to.

The fix in my mind -> would be to have something in the html prevent the <a> tag from being copied when the user right clicks to copy image. Does anybody understand what I am trying to say? I can't really think of an analogy that would be relevant.
Dec 8 '17 #1
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,268
well - this is a pretty strange requirement - since you can only do something that you can control - so only on websites where you have access to the code. there is something like this:

https://developer.mozilla.org/en-US/...Element/oncopy

and take note of something like that as well:

https://www.quirksmode.org/dom/events/cutcopypaste.html

but i suggest to not use it - it alters the normal behaviour of the browser displaying a webpage that a user might expect - so may be one of your colleages wants to copy all while another one doesnt. fiddling around with standard behaviours on a website often leads to annoyance for users. usually the receiving app has to take care of what should be pasted to it - and it does already. since the 'remove hyperlink' option already is there. just dont copy the tag and it wouldnt even be there - so whats copied is usually even pasted - thats how it should work and everyone expect that.

but if you have to for some reason - u can fiddle around with the cut/copy events in this case.
Feb 22 '18 #2

P: 1
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>http://calculator</title>
  4. </head>
  5.  
  6. <body bgcolor="black" topmargin="100" leftmargin="100">
  7. <table border="100" >
  8. <td>
  9. <table border="6" cellspacing="1" cellspadding="2" bgcolor="orang">
  10. <TD>
  11. <form name="Calc">
  12. <table border="10" cellspacing="2" cellspadding="6">
  13. <th bgcolor="blue">
  14. <table  border="1" width="250" size="80" cellspacing="10" cellspadding="15">
  15. <tr>
  16. <td>
  17. <input type="text" name="Numbers" size="16" />
  18. </td>
  19. </tr>
  20. <tr>
  21. <td>
  22. <input type="button" value="  1  " onClick="document.Calc.Numbers.value += '1'"/>
  23. <input type="button" value="  2  " onClick="document.Calc.Numbers.value += '2'"/>
  24. <input type="button" value="  3  " onClick="document.Calc.Numbers.value += '3'"/>
  25. <input type="button" value="  +  " onClick="document.Calc.Numbers.value += '+'"/>
  26. <br />
  27. <input type="button" value="  4  " onClick="document.Calc.Numbers.value += '4'"/>
  28. <input type="button" value="  5  " onClick="document.Calc.Numbers.value += '5'"/>
  29. <input type="button" value="  6  " onClick="document.Calc.Numbers.value += '6'"/>
  30. <input type="button" value="  -   " onClick="document.Calc.Numbers.value += '-'"/>
  31. <br />
  32. <input type="button" value="  7  " onClick="document.Calc.Numbers.value += '7'"/>
  33. <input type="button" value="  8  " onClick="document.Calc.Numbers.value += '8'"/>
  34. <input type="button" value="  9  " onClick="document.Calc.Numbers.value += '9'"/>
  35. <input type="button" value="  x  " onClick="document.Calc.Numbers.value += '*'"/>
  36. <br />
  37. <input type="button" value=" .    " onclick="document.Calc.Numbers.value +='.'"/>
  38. <input type="button" value="  0  " onClick="document.Calc.Numbers.value += '0'"/>
  39. <input type="button" value="  /  " onClick="document.Calc.Numbers.value  += '/ '"/>
  40. <input type="button" value="  %  " onClick="document.Calc.Numbers.value += '/100'"/>
  41. <input type="button" value="  =  " onClick="document.Calc.Numbers.value = eval(Calc.Numbers.value)"/>
  42. <br />
  43. </td>
  44. </tr>
  45. </table>
  46. <input type="button" value="  AC  " onClick="document.Calc.Numbers.value  = ' '"/>
  47.  
  48. </th>
  49. </table>
  50. </form>
  51. <h1>Enjoye <i><samp style="color: blue;" margin="10">calculator</samp></i></h1>
  52. <marquee><h3>Develop by Dhananjay pandey</h3></marquee>
  53. </TD>
  54. </table>
  55. </td>
  56. </table>
  57. </body>
  58. </html>
Feb 22 '18 #3

Frinavale
Expert Mod 5K+
P: 9,731
If you really want to do this, you could try removing the <a> tags around the images and use JavaScript to hook up onClick Events for the images that would do what the <a> tag would have done.

(This assumes that you own the website and can edit the HTML/JavaScript that you are talking about. This cannot be applied to websites that you do not own/control/maintain)
Feb 22 '18 #4

Post your reply

Sign in to post your reply or Sign up for a free account.