gpt4 book ai didi

javascript - Web 应用程序无法在 Edge 浏览器 41 上运行

转载 作者:行者123 更新时间:2023-12-03 00:43:51 25 4
gpt4 key购买 nike

我正在开发 Intranet Web 应用程序。它使用Strust2开发并在weblogic 12c服务器上运行。应用程序在开发环境中运行,没有任何问题 IE(11) 和 Edge(41) Microsoft 浏览器。但部署生产后,它只能工作 IE(11)。它不能在 Edge 上工作。之后我们可以启动登录页面,但无法在 Edge 上导航。Edge 浏览器控制台我们可以看到以下错误。

CSP14321 Resource violated directive 'default-src 'self'' in Content-security-Policy:inline script https://xx.xxx.x.xx/dms/login.action at line
19 column 30.Resource will be blocked

注意:我们的 Web 应用程序支持与 IE11 和 Edge 配合使用。

我尝试了不同的方法,但无法从登录页面导航1.i 删除元标记,例如

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

2.添加元标记,例如

<meta http-equiv="Content-Security-Policy" content="default-src 'self'"/>

上述方法不起作用。要更改内容安全策略,我们的应用程序中没有任何配置文件。请帮助解决此问题

这是登录页面。

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>

<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="tvm.ka.TvsGlobals"%>
<%@ page errorPage="/tvs/ka/common/KvsCommonError.jsp"%>


<head>
<title><s:text name="title.login" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="<%=KvsConfigMgr.strCSS%>" type="text/css" />
<script language="JavaScript" src="<%=kvsConfigMgr.strJS%>KvsCommon.js">

</script>
<script language="JavaScript" src="<%=KvsConfigMgr.strJS%>KvsLogin.js">

</script>
<script language="JavaScript">
var MSG_USERID = "<s:text name="msg.login.userid"/>";
var MSG_PASSWORD = "<s:text name="msg.login.password"/>";
</script>
</head>
<body background="<%=KvsConfigMgr.strLstBg%>" leftmargin="0"
topmargin="0" marginwidth="0" marginheight="0" onLoad="focusFirst()">
<s:form action="login" method="POST">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td valign="top"><div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" background="<%=KvsConfigMgr.strIMG%>topbg.gif">
<table width="100%" border="0" cellpadding="0" cellspacing="0"
background="<%=KvsConfigMgr.strIMG%>topbg.gif">
<tr>
<td><table width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="13%"
background="<%=KvsConfigMgr.strIMG%>logo_bg.jpg"><img
src="<%=KvsConfigMgr.strIMG%>default_01.jpg" width="133"
height="77" alt=""></td>
<td width="87%"
background="<%=KvsConfigMgr.strIMG%>top_bg.jpg"><img
src="<%=KvsConfigMgr.strIMG%>default_02.jpg" width="645"
height="77" alt=""></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div align="left"></div></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="40%">&nbsp;</td>
<td class="errorText">
<%-- <s:if
test="${not empty ${KmsGlobals.GLOBAL_ERR_MSG_LIST}.null}"
scope="request">
<s:iterator value="${KmsGlobals.GLOBAL_ERR_MSG_LIST}.null"
indexId="count" id="errMsg" type="java.lang.String">
<s:property value="errMsg.null" />
<br>
</s:iterator>
</s:if> --%> <s:if test="hasActionErrors()">
<div class="error">
<s:actionerror />
</div>
</s:if>
</td>
</tr>
<tr>
<td class="bodyTextSmall">&nbsp;</td>
<td>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td>To begin, please key in your user id and<br />password
below, and click on login.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td><img src="<%=KvsConfigMgr.strIMG%>tran.gif" width="80"
height="8" /></td>
<td><img src="<%=KvsConfigMgr.strIMG%>tran.gif" width="150"
height="8" /></td>
<td><img src="<%=KvsConfigMgr.strIMG%>tran.gif" width="80"
height="8" /></td>
</tr>
<tr>
<td class="bodyTextBold">User ID</td>
<td><input type="text" name="strUserId" size="20"
tabindex="1" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="bodyTextBold">Password</td>
<td>
<%--
<!--html:password property="strPasswd" autocomplete="off" size="20" tabindex="2"/ -->
I-WAPT-8 Password autocomplete attribute was enabled
Application Penetration Test Fix
--%> <input type="password" name="strPasswd"
autocomplete="off" size="20" tabindex="2" />
</td>
<td><input class="button" style="width: 70px" type="submit"
value="Login" onClick="return validate()" tabindex="3" /></td>
</tr>
<tr>
<td colspan="3" class="errorText">For authorised use only.
Unauthorised use is strictly prohibited.</td>
</tr>
</table>
</td>
</tr>
</table>
<%-- <s:hidden name="dispatch" value="login" /> --%>
<input type="hidden" name="dispatch" value="login" />

</s:form>

<div id="version-tag"><%=KvsConfigMgr.strVer%></div>

<style>
#version-tag {
position: absolute;
bottom: 0;
left: 0;
FONT-WEIGHT: normal;
FONT-SIZE: 11px;
COLOR: rgba(0, 0, 0, 0.6);
FONT-FAMILY: Arial, Verdana, Helvetica, sans-serif;
vertical-align: text-top;
border-color: #0085E0;
}
</style>
</body>

最佳答案

内容安全策略一起,您不能使用内联Javascript,例如onLoad="focusFirst()"

<script language="JavaScript">
var MSG_USERID = "<s:text name="msg.login.userid"/>";
var MSG_PASSWORD = "<s:text name="msg.login.password"/>";
</script>

https://developer.chrome.com/extensions/contentSecurityPolicy#JSExecution

内联 Javascript 代码将不会被执行。

相反,使用以下代码创建一个 Javascript 文件:

document.addEventListener('load', focusFirst);

确保focusFirst此时函数是已知的。

取决于什么focusFirst如果您将监听器附加到 DOMContentLoaded 是否可以提高性能?事件(在解析所有 HTML 时触发,而 load 仅在加载所有链接资源(如图像等)后才会触发)。

请注意内联 <script>内容安全策略处于事件状态时也不会执行 block 。

关于javascript - Web 应用程序无法在 Edge 浏览器 41 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53332754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com