javascript - 使用javascript在qml webview中加载页面时出错
问题描述
我有一个 qt quick 2 应用程序。我正在使用 qml WebView 加载页面
WebView {
id: webview
onUrlChanged: {
}
onLoadingChanged: {
if (loadRequest.status == WebView.LoadStartedStatus) {
console.log("Load start");
} else if (loadRequest.status == WebView.LoadSucceededStatus) {
webview.runJavaScript("document.documentElement.innerHTML",function(result){console.log(result);});
} else if (loadRequest.status == WebView.LoadFailedStatus) {
console.log("Load failed: " + loadRequest.url + ". Error code: " + loadRequest.errorString)
}
}
onStateChanged: {
console.log("** state changed-> "+webview.state);
}
}
我将网址设置https://website.com/user-account/entrypoint/index.html#_formname=passwordRecovery
为加载页面
但我在应用程序输出中看到以下错误并且页面未加载:
Uncaught SyntaxError: Unexpected token '<'
[12984:11328:0625/163955.870:INFO:CONSOLE(1)] "Uncaught SyntaxError: Unexpected token '<'", source: https://website.com/user-account/gwt/entrypoint/entrypoint.nocache.js (1)
[12984:11328:0625/163955.870:INFO:CONSOLE(1)] "Uncaught SyntaxError: Unexpected token '<'", source: https://website.com/user-account/gwt/entrypoint/entrypoint.nocache.js (1)
加载的html是
<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n\t<meta name=\"gwt:property\" content=\"locale=fa\">\n\t<script language=\"javascript\" src=\"entrypoint.nocache.js\"></script>\n</head>\n<body>\n\t<div id=\"busyStatus\"></div>\n\t<div id=\"header\"></div>\n\t<div id=\"messageContainer\"></div>\n\t<div id=\"content\" style=\"width: 97%;\"></div>\n\t<div id=\"footer\"></div>\n\n <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->\n <noscript>\n <div style=\"width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif\">\n Your web browser must have JavaScript enabled\n in order for this application to display correctly.\n </div>\n </noscript>\n\n <iframe src=\"javascript:''\" id=\"__gwt_historyFrame\" tabindex=\"-1\" style=\"position:absolute;width:0;height:0;border:0\"></iframe>\n\n\n\n</body>
在已加载页面中,此消息Your web browser must have JavaScript enabled in order for this application to display correctly
我认为 WebView 存在错误,因为此页面是在 google chrome 中加载的。
解决方案
推荐阅读
- c# - WPF 滑块可在单击时更改按钮颜色
- python - 如何在熊猫图中增加 xticks 的大小
- xml - 第二次创建片段时,片段中的视图相互重叠
- python - python - 如何指示参数应该是对python类型中派生类的引用?
- javascript - JavaScript在localStorage中存储整数,增加值并渲染数据
- apache-spark - Spark:UDF中的访问行
- python - 如何替换多个熊猫列中列表中包含的值
- c++ - 如何在 C++ 中通过 http 发送大型视频文件?
- mysql - MySQL:在过程中动态创建游标
- python - 将多个变量传递给 PoolExecutor