So here is my content.js file.
var title
function content(e) {
title = e.getAttribute('title');
// alert(title); //it alerts the title
window.document.location="movie";
}
function setcontent(){
document.getElementById("name").innerHTML = title; //undefined
}
The content(e) function is called by recommend.html and after it redirects to the page movie.html, setcontent() function will be called by the movie.html.
Here is my movie.html
<html>
<head>
<title>Movie Page</title>
<script type="text/javascript" src="{{url_for('static', filename='content.js')}}"></script>
</head>
<body onload="setcontent()">
<center>
<div id="name"></div>
</center>
</body>
But once the browser redirects to movie.html, it shows undefined in the place of id name instead of the title value. I'm not sure what went wrong. Can somebody help me with this?