开发者

JavaScript settimeout in Qt WebKit

I’m using qt webkit to get page’s content. I开发者_StackOverflow中文版n my program, I catch two signals, QWebFrame’s loadFinished and initialLayoutCompleted, when both signal is received, I’m output the page’s content. But it’s can’t process this page(I need to get google’s content):

<html>
<head>
    <title>test</title>
</head>
<body>
    <script type="text/javascript">
    setTimeout('window.document.location.href="http://www.google.com";',2000
    </script>
</body>
</html>

This page redirect to www.google.com after 2 sec, so , when I get loadFinished and initialLayoutCompleted signal, I get nothing output. So, I want to execute the javascript timing events(redirect to google) immediately ,not to wait 2 sec. Is there any way to do this? Apologize for my poor english!


If I understand your question, all you need to do is change the "2000" into a different number, for example

setTimeout('window.document.location.href="http://www.google.com"',2000);

Or, you can remove the timeout altogether:

window.document.location.href="http://www.google.com"

and it will go immediately, without setting a timeout.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜