Showing posts with label JS. Show all posts
Showing posts with label JS. Show all posts

Wednesday, 20 April 2022

How to Disable copy & Paste on website?

Just put following code in Header section <head> tag.


<!----- Put this code in "<head>" tag   ------>

<script type="text/javascript" language="javascript">

     $(function() {

            $(this).bind("contextmenu", function(e) {

                e.preventDefault();

            });

        });
</script>
<script type="text/JavaScript">
function killCopy(e){ return false }
function reEnable(){ return true }
document.onselectstart=new Function ("return false");
if (window.sidebar)
{ document.onmousedown=killCopy;
document.onclick=reEnable; }
</script>


For more Interesting, Useful Article & codes visit IT New Code.

How to Disable Right click on website?

Just put following code in Header section <head> tag.


<!----- Put this code in "<head>" tag   ------>

<script language="javascript">

                   var message="This function is not allowed here.";
                   function clickIE4(){

                                 if (event.button==2){
                                 alert(message);
                                 return false;
                                 }
                   }

                   function clickNS4(e){
                                 if (document.layers||document.getElementById&&!document.all){
                                                if (e.which==2||e.which==3){
                                                          alert(message);
                                                          return false;
                                                }
                                        }
                   }

                   if (document.layers){
                                 document.captureEvents(Event.MOUSEDOWN);
                                 document.onmousedown=clickNS4;
                   }

                   else if (document.all&&!document.getElementById){
                                 document.onmousedown=clickIE4;
                   }

                   document.oncontextmenu=new Function("alert(message);return false;")

    </script>


For more Interesting, Useful Article & codes visit IT New Code.

How to create a map based on Latitude & Longitude?

Sometimes we need a map based on specified location or dynamically create a map. Then we need to use Latitude & Longitude. Latitude & Longitude provide the perfect location of any place. By finding that we can create a map using it.

Below Gives full code of Creation of map base on Latitude & Longitude.

<html>
<head>
<style type="text/css">
            div#map {
width: 100%;
height: 200px;
            }
</style>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
            var map;
            var geocoder;
            var centerChangedLast;
            var reverseGeocodedLast;
            var currentReverseGeocodeResponse;

            function initialize() {
                var latlng = new google.maps.LatLng(-41.2785537,174.778663);
/*FOR PHP CODE:  var latlng = new google.maps.LatLng("<?php echo $is_about_physical_address_lat; ?>","<?php echo $is_about_physical_address_lng; ?>");  */
                var myOptions = {
                    zoom: 14,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                geocoder = new google.maps.Geocoder();

                var marker = new google.maps.Marker({
                    position: latlng,
                    map: map,
                    title: "Hello World!"
   /*FOR PHP CODE:  title: "<?php echo $is_about_postal_address; ?>, <?php echo $is_about_country_name; ?>"  */
                });

            }
</script>
</head>

<body onLoad="initialize()">
        <div id="map">
            <div id="map_canvas" style="width:100%; height:200px"></div>
            <div id="maparea"></div>
        </div>
</body>
</html>






For more Interesting, Useful Article & codes visit IT New Code.

 

Copyright @ 2016 IT New Code | Developing Code | Designing Code.

Designed by: Ankit Shah