How to use frappe.call on custom html pages

I have created a custom app with page_1.html , page_1.py file have also defined page.js in public/js.
Added the js file to hooks as well
app_include_js = “/templates/pages/page.js”

I am trying to call a custom method on a custom page.
but getting error
Uncaught ReferenceError: frappe is not defined

Refer this.

Edit: On v11, you can use frappe.call on webpages.

1 Like

Hi @Aniket_Shinde1
any updates on this issue?

I figured out the issue it is resolved now

What did you do to resolve this?

@Aniket_Shinde1 you didn’t explain your solution well. please help with detailed solution on this.

The solution that actually works is in this Tutorial 34 and Tutorial 35 by @mymi14s. Tutorial 34 solves the problem and Tutorial 35 fixes some error in 34.

on V14 the issue still

did you find any solution for this issue, i am facing same .

you must change the path for JS (Permission Issue)

Could you please share the directory path?

Tested In Version 14.0

Add Below In Your Page’s head section

	<script type="text/javascript" src="/assets/frappe/dist/js/frappe-web.bundle.HL3LQV7I.js"></script>

    <script type="text/javascript" src="/website_script.js"></script>
    <script type="text/javascript" src="/assets/erpnext/dist/js/erpnext-web.bundle.22EWE5JY.js"></script>

Then add below as the last line before closing tag of your page

< script >frappe.csrf_token = “{{frappe.session.csrf_token}}”;</ script >

To test it, open Developer Tool Then Go To Console… The Paste below
frappe.msgprint(__(‘Hello From Frappe UI’));

I don’t know if this is the best solution, but you can solve it this way.

in head section;

<head>
.....
.....
	<link type="text/css" rel="stylesheet" href="/assets/css/frappe-web-b4.css?ver={{ build_version }}">
	<script>
		window.frappe = {};
		frappe.ready_events = [];
		frappe.ready = function(fn) {
		  frappe.ready_events.push(fn);
		}
		window.dev_server = {{ dev_server }};
		window.socketio_port = {{ (frappe.socketio_port or 'null') }};
		window.show_language_picker = {{ show_language_picker }};
	</script>
.....
.....
</head>

in body section;

.....
<script type="text/javascript" src="/assets/frappe/js/lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/assets/js/frappe-web.min.js?ver={{ build_version }}"></script>
<script type="text/javascript" src="/assets/js/bootstrap-4-web.min.js"></script>
<script>frappe.csrf_token = "{{frappe.session.csrf_token}}"</script>
.....
1 Like