Can't open an HTML on a specific fragment in QT using hash
-
wrote on 20 Jul 2020, 04:35 last edited by a1rltt
I tried this:
QDesktopServices::openUrl(QUrl("file:///" + QCoreApplication::applicationDirPath() + "/HELP.html#pers"));
this:
QUrl url = QCoreApplication::applicationDirPath() + "/HELP.html"; url = QUrl::fromLocalFile(url.toString()); url.setFragment("pers"); QDesktopServices::openUrl(url);
and with just full path, like in browser's search bar:
QDesktopServices::openUrl(QUrl("file:///D:/ucheba/GPO/build-ReeGO-Desktop_Qt_5_13_2_MinGW_32_bit-Release/release/HELP.html#pers"));
in these cases HTML opens, but just in the beginning of the document, ignoring hash (#).
Id is correct - when i use it for linking in browser, #pers appears in a browser's search bar and HTML opens in correct place.
-
wrote on 20 Jul 2020, 06:38 last edited by Bonnie
Hello, are you running in Windows?
If yes, that's not Qt's fault to blame. Qt pass the whole url toShellExecute
Api.
But as discussed in this stackoverflow post:when processing File:/// based URLs in ShellExecute(), the ShellExecute() call will strip off the # and any data it finds after the # before launching the default browser and sending in the HTML page to open. MS's stance is that they do this deliberately to prevent injections into the function.
-
Hello, are you running in Windows?
If yes, that's not Qt's fault to blame. Qt pass the whole url toShellExecute
Api.
But as discussed in this stackoverflow post:when processing File:/// based URLs in ShellExecute(), the ShellExecute() call will strip off the # and any data it finds after the # before launching the default browser and sending in the HTML page to open. MS's stance is that they do this deliberately to prevent injections into the function.
1/3