i have a webpage that loads certain JavaScript packages.
www.mySite.com
If i enter JavaScript commands in the browser console, i am able to interact with them.
Lets take
alert('5')
as a simple example.
I would like the same JavaScript calls to be executed without the browser console but through a specific URL like:
www.mySite.com/?value=5
so that this leads to an execution of my JavaScript commands?
Without the Page beeing reloaded/refreshed but staying in the actual state.
My approach was to catch the extended URL in my Django View and execute the JavaScript command.
View:
class ShowPage(View):
def get(self, request, caseId):
value = request.GET.get('value', '')
if(value is not ''):
// execute JavaScript here...
return HttpResponse("<script>alert(" + value + ")</script>")
else:
...
return render(request, 'template.html', context)
But this leads to a loss of my page where i entered the URL.
Does anyone has an idea how to preserve the actual Browser content? So that it is possible to call the loaded Javascript packages?
Another idea was to call JavaScript through Ajax. But how do i map a URL in Django to a Ajax request?