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>
0

First, you'll need a way to discriminate amongst the various <a tags, we'll add to the url an extra parameter named filename, so if the link looks like: /mypage will become /mypage?filename=test

Now the page will be loaded by Joomla ignoring the extra parameter, but it will still show in the url. Now your script can decode it check this post out or any other search for 'get url params'


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.