[webkit-help] problems with WindowCloseRequested signal

Thomaz de Oliveira dos Reis thor27 at gmail.com
Tue Oct 25 12:08:01 PDT 2011


Hi!

I'm having a problem with this signal when javascript calls
"window.close" in pages that have already being navigated.

For exemple:

we have is a.html:
<a href="b.html">link to B</a><br/>
<a href="#" onclick="window.close()">close this window</a>

and b.html:
<a href="a.html">link to A</a><br/>
<a href="#" onclick="window.close()">close this window</a>


If I open my custom browser with webkit, and click on "close this
window" the signal is emitted
But if I click on "Link to B" and then on "close this window" the
signal is not emitted.

First I tought that this would be something related for misusing
pyqt-webkit[1], but then after trying the same code with
python-webkit-gtk I've got exactly the same problem.

So, what I'm missing here? It's something related to Webkit or even
javascript/html specification that I didn't get it?

Thanks for the help!


[1] message posted on PyQT list, few days ago:
Hi,

I have this simple code:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

def close(): sys.exit()

app = QApplication(sys.argv)

web = QWebView()
QObject.connect(web.page(),SIGNAL("windowCloseRequested ()"),close)

web.load(QUrl("a.html"))
web.show()

sys.exit(app.exec_())

and 2 more files, that is a.html:
<a href="b.html">link to B</a><br/>
<a href="#" onclick="window.close()">close this window</a>

and b.html:
<a href="a.html">link to A</a><br/>
<a href="#" onclick="window.close()">close this window</a>

When you load the app, and then clicks on "close this window" the window closes
But if you click on link to B and then click on "close this window"
the window doesn't closes.

Why this happens? There is any solution so this signals keep working
even after loading another URL?


thanks!


More information about the webkit-help mailing list