Appeler une page htm et pointer sur une ancre

Résolu
p.chirossel Messages postés 5 Date d'inscription mardi 4 mai 2021 Statut Membre Dernière intervention 3 novembre 2021 - 2 nov. 2021 à 19:59
vb95 Messages postés 3472 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 13 avril 2024 - 4 nov. 2021 à 18:07
Bonjour, j'ai développer une application sou vb express 2019 . je n'arrive pas à ouvrir une page htm à un endroit précis ( ancre)

mon code
h = "D:/Philippe/Projet%20Meca%20Magister/projet%20statique%20expert%20-%2008%20aout%202021/Projet1.NET1/bin/aide%20prof/modelisation%20des%20liaisons/modelisation%20des%20liaisons.htm#torseur_torseur_2d"
Dim MonURL As String = "file:///" & h

Process.Start(MonURL)

Ce code ouvre bien la page ( mais ne tient pas compte de l'ancre #torseur_torseur_2d).
( le lien apparait sur le navigateur :

file:///D:/Philippe/Projet%20Meca%20Magister/projet%20statique%20expert%20-%2008%20aout%202021/Projet1.NET1/bin/aide%20prof/modelisation%20des%20liaisons/modelisation%20des%20liaisons.htm ( ancre supprimée)



A noter: Si je copie ce lien dans mon navigateur( firefox ou microsoft edge) , il pointe sur l'ancre.

file:///D:/Philippe/Projet%20Meca%20Magister/projet%20statique%20expert%20-%2008%20aout%202021/Projet1.NET1/bin/aide%20prof/modelisation%20des%20liaisons/modelisation%20des%20liaisons.htm#torseur_torseur_2d


Remarque : cette commande a eu fonctionné dans le passé ( je ne l'avais pas retesté récemment). je suis un peu perdu. merci pour votre aide

3 réponses

vb95 Messages postés 3472 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 13 avril 2024 169
Modifié le 3 nov. 2021 à 17:57
Bonjour
2 petits détails d'abord
1) VB Express 2019 n'existe pas à ma connaissance ( c'est VB Net dans Visual Studio Community 2019 qui existe )
2) Pour poster du code prière de suivre ce tuto : https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code

A tout hasard en remplaçant "%20" par un espace comme ci-dessous cela donne quoi ?
dim h as String =  "D:/Philippe/Projet Meca Magister/projet statique expert- 08 aout 2021/Projet1.NET1/bin/aide prof/modelisation des liaisons/modelisation des liaisons.htm#torseur_torseur_2d"
Dim MonURL As String = "file:///" & h
Process.Start(MonURL)


Et en remplaçant seulement le # par %23 en laissant la chaine telle qu'elle est avec ses "%20"

0
p.chirossel Messages postés 5 Date d'inscription mardi 4 mai 2021 Statut Membre Dernière intervention 3 novembre 2021
3 nov. 2021 à 19:19
merci pour la réponse. j'ai aussi essayé avec %23 .
----------------------------------------------------------------------
Remarque :problème résolu
A la place de :Process.Start(MonURL), j'appelle la fonction DemarrerApplication

( je n'ai pas le niveau pour l'analyser mais cela fonctionne)

------------------------------------------------------------------------------

identificateur_navigateur = DemarrerApplication(navigateur, MonURL)

Public Function DemarrerApplication(ByVal NomApplication$, Optional ByVal ParametresApplication$ = "") As Integer
' ????????????????????? DEMARRERAGE DE L'APPLICATION ?????????????????????
Try
Dim Processus As New System.Diagnostics.Process()
If NomApplication <> String.Empty And ParametresApplication <> String.Empty Then
With Processus
'Nom de l'executable à lancer.
.StartInfo.FileName = NomApplication
'Argument a passer
.StartInfo.Arguments = ParametresApplication
'Démarrage du processus.
.Start()
End With
Else
With Processus
.StartInfo.FileName = NomApplication
.Start()
End With
End If
DemarrerApplication = Processus.Id
Catch ex As Exception

End Try
End Function
0
vb95 Messages postés 3472 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 13 avril 2024 169
4 nov. 2021 à 18:07
Bonjour
C'est plus joli et agréable à lire ainsi ( voir le point 2 de mon premier message )
Public Function DemarrerApplication(ByVal NomApplication as String, Optional ByVal ParametresApplication as String = String.Empty) As Integer
' ????????????????????? DEMARRERAGE DE L'APPLICATION ?????????????????????
Try
    Dim Processus As New System.Diagnostics.Process()
    If NomApplication <> String.Empty And ParametresApplication <> String.Empty Then
        With Processus
             .StartInfo.FileName = NomApplication  ' Nom de l'executable à lancer.
             .StartInfo.Arguments = ParametresApplication ' Argument a passer
             .Start() ' Démarrage du processus.
        End With
    Else
        With Processus
            .StartInfo.FileName = NomApplication
            .Start()
        End With
    End If
    DemarrerApplication = Processus.Id
Catch ex As Exception

End Try
End Function


De plus on est plus au temps du QuickBasic où l'on mettait un $ pour une chaine de caractère .
Je ne sais pas avec quelle version de VB Net vous travaillez mais si celle-ci est récente vous pouvez supprimer les Byval dans les Sub ou Function du projet .

Votre souci étant résolu veuillez mettre ce message du forum comme étant résolu .
Merci

0
Rejoignez-nous