webbrowser fragment identifier

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scottbvfx

    webbrowser fragment identifier

    Hi,

    I'm trying to launch a web browser along with an html file with a
    fragment identifier in its path. I'm using the webbrowser module for
    this.
    ie. webbrowser.open ('file:///C:/myfile.html#Som eEntryInTheHTML ')

    for some reason it is truncating the path to 'file:///C:/myfile.html'.

    Does anyone know a way of getting the fragment identifier in there
    (with webbrowser module or any other)?

    Thanks,
    -Scott
  • Tim Golden

    #2
    Re: webbrowser fragment identifier

    scottbvfx wrote:
    Hi,
    >
    I'm trying to launch a web browser along with an html file with a
    fragment identifier in its path. I'm using the webbrowser module for
    this.
    ie. webbrowser.open ('file:///C:/myfile.html#Som eEntryInTheHTML ')
    >
    for some reason it is truncating the path to 'file:///C:/myfile.html'.
    >
    Does anyone know a way of getting the fragment identifier in there
    (with webbrowser module or any other)?
    No expertise here: just poking around. This seems to be
    a slight peculiarity of browser and os cooperation. As
    a comparison, try running os.startfile ("file://....#..")
    or just pasting it into the command line. I don't understand
    why this should be but it seems to lose it there as well.

    Randomly tested on my XP box with Firefox 3 & IE 7:

    Input: Start Run firefox c:\temp\t.html# chapter-i
    Result: URL is escaped so ff3 starts with non-existent file:///c:/temp/t.html%23chapte r-i

    Input: Start Run file:///c:\temp\t.html# chapter-i (with ff3 as default)
    Result: URL fragment is stripped so ff3 starts with file:///C:/temp/t.html

    Input: Start Run iexplore c:\temp\t.html# chapter-i
    Result: Gets it right: ie7 starts with file:///C:/temp/t.html#chapter-i

    Input: Start Run file:///c:\temp\t.html# chapter-i (with ie7 as default)
    Result: URL fragment is stripped so IE7 starts with file:///C:/temp/t.html


    A very quick perusal of the webbrowser source suggests it does nothing
    more sophisticated than finding possible browsers, starting with firefox,
    and stopping when it finds it. It then uses that as the command-line prefix
    to whatever url is passed. So no stripping of url fragments happening there.

    TJG

    Comment

    • Gabriel Genellina

      #3
      Re: webbrowser fragment identifier

      En Thu, 18 Sep 2008 21:53:22 -0300, scottbvfx <scotballard@gm ail.com>
      escribió:
      I'm trying to launch a web browser along with an html file with a
      fragment identifier in its path. I'm using the webbrowser module for
      this.
      ie. webbrowser.open ('file:///C:/myfile.html#Som eEntryInTheHTML ')
      >
      for some reason it is truncating the path to 'file:///C:/myfile.html'.
      >
      Does anyone know a way of getting the fragment identifier in there
      (with webbrowser module or any other)?
      It's not Python which truncates the path - webbrowser.open doesn't modify
      the url given.
      Looks like you're on Windows. Internet Explorer exposes a COM interface
      that you may use to control it. Google for "python IE automation"

      --
      Gabriel Genellina

      Comment

      Working...