如何使用JavaScript将凭据传递给iframe

编程入门 行业动态 更新时间:2024-10-25 10:28:24
本文介绍了如何使用JavaScript将凭据传递给iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在Kibana上工作,并显示我的kibana仪表板,我在HTML中使用iframe,并且我的kibana仪表板具有[使用ReadOnlyRest插件]的身份验证.

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.

user1:user1 @ myhost:5601/app/kibana#/dashboard/xyz_dashboard .

现在,如果我想使用动态凭据值代替"user1:user1" ,我想使用JavaScript或Ajax或Angularjs,并使用rest.

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.

请帮助我.

推荐答案

您可以尝试在js代码中创建一个变量.看看window对象,您可能很想从那里获取用户.对于前:`

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 :`

<script> 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; } </script>`

更多推荐

如何使用JavaScript将凭据传递给iframe

本文发布于:2023-11-17 05:52:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609056.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:凭据   如何使用   JavaScript   iframe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!