我看了一下你的问题。实际上,你需要在第一页创建一些数据并初始化第二页。
如果你直接使用标准浏览器访问第二页(
https://www.jeopardy.com/be-a-contestant/practice-test-client),你会得到与UWP应用程序相同的行为。
如果你启动浏览器的调试工具(F12),你会看到主要的脚本是:
所以,我已经通过在第二个页面使用调试器控制台注入一些内容来启动计时器(我已经在Firefox中测试过)。以下是执行步骤(将整个内容复制/粘贴到控制台中并执行):
var s = document.createElement("script");s.type = "text/javascript";s.src = "https://www.jeopardy.com/Assets/jeopardy/easyxdm/exdm_helper.js";$("head").append(s);
s.src = "https://www.jeopardy.com/Assets/jeopardy/js/main.js";$("head").append(s);
s.src = "https://www.jeopardy.com/Assets/jeopardy/js/practice_test_launcher.js";$("head").append(s);
backendUserCheck(); test_launcher.init();test_launcher.testWindow = window;
$('body').append('<div data - testfile = "/Assets/jeopardy/json/test_practice_2011.json" data - testid = "1" class="button launch_practice_test" data-testtype="adult">Take the practice test</div>');
var button = $('.launch_practice_test');test_launcher.testQuestionsFile = button.attr('data-testfile');test_launcher.testType = button.attr('data-testtype');test_launcher.testTitle = button.attr('data-testtitle');test_launcher.testID = button.attr('data-testid');
testModule.parentRef=test_launcher;
testModule.deleteLocalStorage();
testModule.checkLocalStorage();
testModule.getLocalStorage();
testModule.testID = testModule.parentRef.getTestID();
testModule.testType = testModule.parentRef.getTestType();
testModule.testFile = testModule.parentRef.getFile();
testModule.hardwareTest = testModule.parentRef.checkIfDryRun();
testModule.sendTestStart();
trace = function(){};
trace = {
output : true,
queue : [],
push : function(data)
{
trace.queue.push(data);
if(trace.output)
{
trace.post();
}
return
},
post : function()
{
$.each(trace.queue, function(i,arr)
{
trace.log(arr);
});
trace.queue = [];
return
},
dump : function()
{
trace.post();
return
},
log : function(data)
{
if (!window.console){ console = {log: function() {}} };
console.log(data);
return
}
};
testModule.loadQuiz();
testModule.parentRef=test_launcher;
testModule.startDate = testModule.parentRef.getStartDateInMS();
这段初始化代码是从之前提到的两个主要脚本的onload事件或init方法中提取的。计时器会被执行,但问题随后不会出现。我认为需要来自
practice_test_client.js中的
alertParent和
setTestData代码。我让你调试网页并找到必要的方法执行。
要在您的UWP中使其工作,您需要向您的Web视图注入这些数据。为此,您可以尝试使用
InvokeScriptAsync
方法,或使用HttpClient下载页面,并在将结果页面加载到webView之前将初始化命令添加到其中。
string content = "";
using (HttpClient client = new HttpClient())
{
content = await client.GetStringAsync(new Uri("https://www.jeopardy.com/be-a-contestant/practice-test-client"));
}