0

I have two articles in my Joomla site. One article has various links to the same article. The other article display, with code of java script, the HTML content of a file depending on what link was clicked in the previous article. How can I send a variable with the option that the user clicked and get that variable in the other article?

This is the code of javascript that show the file in the second article. Right now shows a specific file but I want that the file name were the option that received from the first article

<script language="javascript" type="text/javascript">
  file="http://1.1.1.1/mysite/files/test.html"
  var rawFile = new XMLHttpRequest();
  rawFile.open("GET", file, false);
  rawFile.onreadystatechange = function ()
  {
    if(rawFile.readyState === 4)
    {
      if(rawFile.status === 200 || rawFile.status == 0)
      {
        var allText = rawFile.responseText;
        document.getElementById("content_file").innerHTML=allText;
      }
    }
  }
  rawFile.send(null);
</script>

1 Answers1

0

You can just add parameters to the links, and retrieve the values in js, see How can I get query string values in JavaScript?

JulienV
  • 775
  • 7
  • 12
  • This is effectively a link-only answer. If you wish to post a link, please do so via a comment under the question. If you believe the link fully solves the question, you can flag to close as a duplicate. If you want to post an answer, please ensure that the majority of your support is "written out" in your answer. – mickmackusa Jun 28 '18 at 06:51