Quantcast
Channel: Serif Software Forums (Closed) - WebPlus
Viewing all articles
Browse latest Browse all 4745

WebPlus X5: Disable Right Click on Image and Iframe - How To's

$
0
0
Do you ever need a way to disable right click on an image on your site so the user does not save your image?

How about if you use an i-frame? Do you ever want to disable the ability to reload the contents in a new window?

Well, while it is not hack proof, here is a good solution.

Here is some instruction for Serif users:

For Images:
Once an image is inserted into your document, right click on your image and go to attach html

Look for the code that looks similar to this, note that the width, height, and position will be different than what is shown here and it is not important:

Code:

<img src="wpimages/YOUR_IMAGE_NAME.jpg" width="700" height="77" border="0" alt="" style="position:absolute;left:28px;top:34px; /*Tag Style*/" __AddCode="here">
Where it has __AddCode="here">

add this:
Code:

"oncontextmenu="return false;"
in place of __AddCode="here"

Done, its that easy!

For I-frame:
You will need to add an HTML Code Fragment and paste this to the body:

Code:

<script type="text/jscript">
  function disableContextMenu()
  {
    window.frames["Your_iframe_Name"].document.oncontextmenu = function(){alert("NOT ALLOWED!"); return false;}; 
    // Or use this
    // document.getElementById("Your_iframe_Name").contentWindow.document.oncontextmenu = function(){alert("NOT ALLOWED!"); return false;};;   
  } 
</script>

Make sure you place this HTML Code Fragment on the Same Page where your iframe is located.

Finally you will need to add some code to the HTML of the iframe itself. Right click on your iframe and go to attach html

Where it has __AddCode="here">

add this:
Code:

onload="disableContextMenu();" onMyLoad="disableContextMenu();"
in place of __AddCode="here"

This will display an alert message that says "NOT ALLOWED! You can change that to whatever you want.

It is that easy! Your done!

Viewing all articles
Browse latest Browse all 4745

Trending Articles