Board index » cppbuilder » hpow to obtain the base url in browser

hpow to obtain the base url in browser


2003-12-18 08:19:07 AM
cppbuilder51
Hi
How does one obtain the base url form a HTML Document downloaded in a
TCppWebBrowser control using the DOM
If there is no <BASE>tag specified in the HTML how else can one obtain it?
I doubt whether IHTMLBaseElement would work??
Bye
Tim
 
 

Re:hpow to obtain the base url in browser

Tim Chemaly wrote:
Quote
Hi
How does one obtain the base url form a HTML Document downloaded in a
TCppWebBrowser control using the DOM
If there is no <BASE>tag specified in the HTML how else can one obtain it?
I doubt whether IHTMLBaseElement would work??


Bye
Tim


BeforeNavigate event contains the url being accessed.
hth,
.a
 

Re:hpow to obtain the base url in browser

"Alex Bakaev [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
BeforeNavigate event contains the url being accessed.
That is not the same thing that Tim is asking for. A "base" url for a given
page is a folder of a url that any relative <a>links will be relative to.
For example, if you had the following links:
--- www.somesite.com/myfolder/subfolder/somepage.html ---
<a href="../page1.html">...</a>
<a href="../page2.html">...</a>
The base URL would be "www.somesite.com/myfolder" rather than
"www.somesite.com/myfolder/subfolder". You could use a <base>tag to
simplify the links, ie:
--- www.somesite.com/myfolder/subfolder/somepage.html ---
<base href="..">
<a href="page1.html">...</a>
<a href="page2.html">...</a>
The <base>tag really becomes useful if you have a bunch of links to a
completely different site, ie:
--- www.somesite.com/myfolder/subfolder/somepage.html ---
<a href="www.anothersite.com/page1.html">...</a>
<a href="www.anothersite.com/page2.html">...</a>
You could express it like this instead:
--- www.somesite.com/myfolder/subfolder/somepage.html ---
<base href="www.anothersite.com">
<a href="page1.html">...</a>
<a href="page2.html">...</a>
Gambit
 

{smallsort}

Re:hpow to obtain the base url in browser

"Tim Chemaly" < XXXX@XXXXX.COM >wrote in message
Quote
How does one obtain the base url form a HTML Document
downloaded in a TCppWebBrowser control using the DOM
Call QueryInterface() on the Document property to obtain an IHTMLDocument3
interface, and then use its baseURL property. MSDN says it is not
supported, but you never know.
If that does not work, then you will have to get the IHTMLDocument2
interface instead, and use its "all" collection to find an IHTMLBaseElement
item in the collection.
Quote
If there is no <BASE>tag specified in the HTML how else can one obtain
it?
You don't, because there won't be any base url to begin with. You will just
have to grab the actual URL for the page itself and strip off the page's
filename.
Quote
I doubt whether IHTMLBaseElement would work??
Why do you think that? That is exactly what it is for - it represents a
<base>element in the page.
Gambit