1

I have a fullcalendar being accessed within an iframe from both a standalone Java application and a browser based web application. I was working on the web application first of all and set the username using a cookie in Javascript. This will not work however from the standalone Java application.

What would be the easiest way of passing the username from Java to the iframe?

I'm thinking it may be over complicated to set the cookies from the Java application.

Another option is to just add the username into the URL (e.g. "../fullcalendar/index.php?username=admin")

I have tested this by pasting the URL into the browser with the username included. Then entered the following code in index.php (actually a HTML file, but saved as .PHP)

<script>       
    console.log(document.getElementById("username").value);
</script>

Output is: undefined.

Is it possible to just concatenate the username onto the URL or does it need to be set somehow?

Any advice would be much appreciated.

CollinsPED
  • 27
  • 7

1 Answers1

0

The easiest thing to do here is to put the username in the url (e.g. "../fullcalendar/index.php?username=admin") by either just changing the url directly, or by using

request.setAttribute("username", theUsername);

and then put a small bit of PHP code into the HTML file. For example:

<span id="username"><?php echo $_GET["username"]; ?></span>

If you then want to get the username from the JavaScript, use

var username = document.getElementById("username").innerHTML;
4castle
  • 32,613
  • 11
  • 69
  • 106