I'm working on something much bigger but I will resume to provide a more simple example to my problem.
Let's say I have two html pages. On 1st page I have three anchor tags which all links to the 2nd page.
<a href="nextpage.html"> You clicked Red </a>
<a href="nextpage.html"> You clicked Blue </a>
<a href="nextpage.html"> You clicked Yellow </a>
The 2nd page has only an empty paragraf.
When you click one of the three links on 1st page and get directed to the 2nd page, the 2nd page is supposed to contain the text of the respective clicked <a> tag.
I've write my javascript(Jquery) code like this in a .js file and included in the <head> of both pages :
$(document).ready(function() {
$('a').click(myFunction);
});
function myFunction() {
var text = $(this).text();
$("p").html(text);
}
The above code should work but sadly it doesn't. I run a test in console.log and the result I get when I click a link and get directed to 2nd is undefined. I don't know exactly why this happens since I included the javascript file on both pages and should comunicate with eachother.
<a>text in a Get or Post variable so you can get it from within your other page.single page appbut THREE DIFFERENT INSTANCES of the "same" app... unfortunately, just because you included the sameJavaScriptfile inpage1.html,page2.html, andpage3.html, each of thesehtmlfiles get their "own instance" of theJavaScript "program"that's included in thesomescript.jsfile... this is why it isundefined