...
...
...
2.具体操作步骤
1、编写JS脚本实现登录,核心脚本代码如下所示,surl为Smartbi登录成功后自动根据参数跳转的地址,furl是Smartbi登录失败后自动根据参数跳转的地址。
代码块 | ||||
---|---|---|---|---|
| ||||
<form method="POST" id="formLogin" onsubmit="go();return false">
<p>用户:<input type="text" name="user" size="20" value="admin"></p>
<p>密码:<input type="text" name="password" size="20" value="manager"></p>
<p>登录成功后的跳转地址:<input type="text" name="surl" size="20" value="manager"></p>
<p>登录失败后的跳转地址:<input type="text" name="furl" size="20" value="manager"></p>
<p><input type="submit" value="确定" name="B1"></p>
</form>
function go() {
formLogin.action = "http://localhost:18080/smartbi/vision/login.jsp";
formLogin.user.value = "admin";
formLogin.password.value = "manager";
formLogin.surl.value = " "; // 登录成功后的跳转地址;若该地址为外部链接,需要包含协议名,如以 http:// 开头
formLogin.furl.value = " "; // 登录失败后的跳转地址
formLogin.submit();
return true;
} |
2、前端登录后,需要有相应的注销代码,核心注销代码如下。
代码块 | ||||
---|---|---|---|---|
| ||||
<form method="POST" id="formLogout" onsubmit="go();return false">
<p>注销成功后的跳转地址:<input type="text" name="surl" size="20" value="manager"></p>
<p>注销失败后的跳转地址:<input type="text" name="furl" size="20" value="manager"></p>
<p><input type="submit" value="确定" name="B1"></p>
</form>
function go() {
formLogout.action = "http://localhost:18080/smartbi/vision/logout.jsp";
formLogout.surl.value = " "; // 注销成功后的跳转地址 为空时自动跳转到smartbi的index.jsp
formLogout.furl.value = " "; // 注销失败后的跳转地址 为空时自动跳转到smartbi的index.jsp
formLogout.submit();
return true;
} |
3、gif演示示例的源码请参考:在页面中使用Form登录.rar。