Navigating the browser << Previous |  Contents  |  Next >>  ]
Navigating the browser Implemented by Gecko and provides methods for...
  • back/forward, canGoBack/canGoForward.
  • URI loading, stoping, reloading.
  • The currently loaded URI.
  • the nsISHistory (session history) interface bound to this nsWebBrowser.

This snippet will cause a URL to be loaded by Gecko. The contents will be rendered in the window you just setup.
  #include "nsIWebNavigation.h"

  nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(webBrowser);

  // Load a URI.
  rv = webNav->LoadURI(
         NS_LITERAL_STRING("www.mozilla.org"),
         LOAD_FLAGS_NONE,
         nsnull, nsnull, nsnull); // referrer, postdata & headers
  if (NS_FAILED(rv)) return rv;