Lauching HTML document with anchor (reference inside page) problem

Discussion in 'Internet Explorer' started by Lars-Erik Østerud, Mar 19, 2007.

  1. I can't get this to behave equal on different versions.

    I need to launch the default browser with a HTML document and a
    reference to an anchor (A NAME reference) inisde that document:

    file:///D:/docs.html#chapter1 does NOT work (no program first)

    For Internet Explorer 6:

    - iexplore.exe file:///D:/docs.html#chapter1 works OK
    - explorer.exe file:///D:/docs.html#chapter1 does NOT work

    For Internet Explorer 7:

    - iexplore.exe file:///D:/docs.html#chapter1 does NOT work
    - explorer.exe file:///D:/docs.html#chapter1 work OK

    For Firefox 2.0

    - firefox.exe file:///D:/docs.html#chapter1 works OK
    - explorer.exe file:///D:/docs.html#chapter1 does NOT work

    Why the difference? All launch the HTML document, but in the cases
    marked "does NOT work" the reference ("#chapter1") is lost :-(

    Is there a safe way to do this that will always work right?

    Very strange that IE6 and IE7 does not work equal in any case !!!

    I can assume that the user has IE6 or IE7 on the PC, but when they
    need different command-line to work, then I can't predict that...

    Is there a common way that will work for both IE6 and IE7, or a way to
    check what is the default browser on the system (then my program can
    choose the right command line if I knows if it is IE6, IE7 or Firefox)
     
    Lars-Erik Østerud, Mar 19, 2007
    #1
    1. Advertisements

  2. Lars-Erik Østerud

    Ron Sommer Guest

    How do you know that the file is always going to be on D?
    --
    Ronald Sommer

    :I can't get this to behave equal on different versions.
    :
    : I need to launch the default browser with a HTML document and a
    : reference to an anchor (A NAME reference) inisde that document:
    :
    : file:///D:/docs.html#chapter1 does NOT work (no program first)
    :
    : For Internet Explorer 6:
    :
    : - iexplore.exe file:///D:/docs.html#chapter1 works OK
    : - explorer.exe file:///D:/docs.html#chapter1 does NOT work
    :
    : For Internet Explorer 7:
    :
    : - iexplore.exe file:///D:/docs.html#chapter1 does NOT work
    : - explorer.exe file:///D:/docs.html#chapter1 work OK
    :
    : For Firefox 2.0
    :
    : - firefox.exe file:///D:/docs.html#chapter1 works OK
    : - explorer.exe file:///D:/docs.html#chapter1 does NOT work
    :
    : Why the difference? All launch the HTML document, but in the cases
    : marked "does NOT work" the reference ("#chapter1") is lost :-(
    :
    : Is there a safe way to do this that will always work right?
    :
    : Very strange that IE6 and IE7 does not work equal in any case !!!
    :
    : I can assume that the user has IE6 or IE7 on the PC, but when they
    : need different command-line to work, then I can't predict that...
    :
    : Is there a common way that will work for both IE6 and IE7, or a way to
    : check what is the default browser on the system (then my program can
    : choose the right command line if I knows if it is IE6, IE7 or Firefox)
    : --
    : Lars-Erik - http://www.osterud.name - ICQ 7297605
     
    Ron Sommer, Mar 19, 2007
    #2
    1. Advertisements

  3. That is in a config file :) So that is no problem.
    The problem is how to launch with the anchor (the # part)
     
    Lars-Erik Østerud, Mar 19, 2007
    #3
  4. Lars-Erik Østerud

    Ayush Guest

    Lars-Erik Østerud wrote ::
    runDll32 shell32,ShellExec_RunDLL filepath.htm

    the above will launch the filepath.htm in the browser associated with .htm file.
    This works on all file types.

    you can also use full paths-
    %windir%\system32\runDll32.exe %windows\system32\shell32.dll,ShellExec_RunDLL
    filepath.htm


    Good Luck, Ayush.
     
    Ayush, Mar 19, 2007
    #4
  5. Sadly that does NOT use the chapter reference (the "#chapter1" part).
    So I cannot use that way, it just opens the document at the start :-(

    I need to find a way that will jump to the right chapter when that is
    included in the URL (see the original mail). And that seems to work
    right for IE6 and Firefox, but not for IE7 (to make it work in IE7 I
    must feed the URL to "explorer.exe" and not to "iexplore.exe").

    Still don't see why there are those different behaviours :-(

    Any other idea on a "universal way" to launch an HTML-file AND jump to
    the anchor at the end (the "#chapter1" part) that works on all
    browsers?
     
    Lars-Erik Østerud, Mar 19, 2007
    #5
  6. Still don't see why there are those different behaviours :-(

    From
    http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx
    "IE7 introduced a regression in this behavior. The bug is as you noted,
    when passed a file URI on the command line containing a fragment, the
    fragment is dropped during navigation."

    Thus it appears to be a bug in IE7. They don't give a workaround, so it's
    not much help, sorry.
     
    Code-Curious Mom, Mar 19, 2007
    #6
  7. But there is a work-a-round. If you pass the URL to "explorer.exe"
    instead of "iexplore.exe" then it is launched with the "fragment"!

    But this only works with IE7 (if you do that with IE6 then the
    "fragment" is dropped, exacly the opposite behavior)...

    So to make it always work I need to text the following:

    1) Is it IE7, then launch URL to "explore.exe"
    2) Other browser, find EXE-file and use that

    So what I need to know then is

    1) How to check if IE7 is installed from Borland Delphi
    2) How to find the name of the default browser executable

    I guess both can be read from the registry.
    But where is the best place to find that info?
     
    Lars-Erik Østerud, Mar 19, 2007
    #7
  8. Lars-Erik Østerud

    Ayush Guest

    Lars-Erik Østerud wrote ::
    1-Check version of iexplore.exe file.
    2-Registry
    Read default of HKCR\.htm
    Read HKCR\'the Default Of .htm'\Shell\Command



    Good Luck, Ayush.
     
    Ayush, Mar 19, 2007
    #8
  9. Yep, now got it... Check the default browser first.
    If it is anything else that IE I use it as it is.
    If it is "iexplore.exe" then I check the version.
    And if it is 7.x I change string to "explore.exe".

    Then the local file URL with a "#chapter" always
    launches at it should. A bit messy, but it works.
     
    Lars-Erik Østerud, Mar 20, 2007
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.