Quantcast
Channel: Live News for Yii Framework
Viewing all articles
Browse latest Browse all 3361

[Wiki] Yii2 Enable content protection with own javascript file in the project frontend

$
0
0

If you are trying to put own java script function on application view, this is perfect article

step1

create js folder under /frontend/web/?

step2

create file site.js under /frontend/web/js/

step3

write in site.js

$('body').bind('copy paste cut drag drop', function (e) { e.preventDefault(); });

step4

create some changes in frontend/assets/AppAsset.php

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
'css/site.css',
    ];
    public $js = [
        **'js/site.js',**
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];
}

step5

Its done check your application on browser.


Viewing all articles
Browse latest Browse all 3361

Trending Articles