How to pass credentials to iframe using javascript Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to pass credentials to iframe using javascript without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am working on Kibana, and to display my kibana’s dashboard, I am using iframe in HTML, and my kibana dashboard has authentication [using ReadOnlyRest Plug-in].

To pass credentials I used the below format.


Now if I want the dynamic credentials value in place of "user1:user1" I want to use JavaScript or Ajax or Angularjs using rest.

And I am seriously blank and searched a lot, but got nothing which I can understand.

Please assist me.


You can try and make a variable in your js code.Look at the window object, you might be abble to get the user from there. For ex :`

  function myFunction() {
  var user = getCurrentUser(); // where getCurrentUser is a way to get the user
  var source =  user + "@localhost:5601/app/kibana#/dashboard/…;;";
  document.getElementById("myFrame").src = source;
We are here to answer your question about How to pass credentials to iframe using javascript - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji