Search code examples
c++anchorshellexecute

How can i jump to a webpages anchor <a> tag using ShellExecute in C++?


I'm currently opening a webpage succesfully in this manner, for example

ShellExecute(NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL);

However what I really need to do is be able to jump to an anchor tag, like 'mypage.html#middle'. When I just append it to the end of the URL string, the webpage only opens at the file specified, and won't jump to the tag, nor will it be in the address bar.

Thanks.


Solution

  • Okay, so I've managed to achieve this using a slightly different technique. However when using this method you have to define which browser to open it with, which might be considered an issue for those concerned about deploying it to a large number of users (fortunately, in my case this isn't true).

    ShellExecute(NULL, "open", "iexplore", urlString, NULL, SW_SHOWNORMAL);
    

    Where 'urlString' is the web address, with the anchor at the end.

    Thanks all.