Home All Groups Group Topic Archive Search About

Save a web page - hyperlinks question



Author
26 Aug 2006 4:13 PM
fiefie.niles
I would like to save a web page to a file and have the hyperlinks work
when I bring the file back up. If the web page has a hyperlink like the
following
<a href="OurWeb/News/abcFile.htm">, after saving the file and showing
it on the screen, and you try to click on the link, it will try to go
to C:\OurWeb\News\abcFile.htm instead of
www.MyWebSite.com/OurWeb/News/abcFile.htm.
If I am on the website www.MyWebSite.com, and do "File" - "Save As" and
under "Save as Type" select "Web Page, complete (*.htm,*.html)", it
will save the hyperlink as www.MyWebSite.com/OurWeb/News/abcFile.htm.

How can I programmatically do "File" - "Save As" and under "Save as
Type" select "Web Page, complete (*.htm,*.html)" ? Thank you.

This is how I save the web page:
WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER,
"c:\abc.htm", null

OR

   Set fs = CreateObject("Scripting.FileSystemObject")
   Set filePtr = fs.CreateTextFile("c:\abc.htm", True)
   filePtr.WriteLine (WebBrowser1.Document.body.innerHTML)

Author
26 Aug 2006 4:24 PM
Jay
Well in the pages. why dont you just set a base "href" at the top of each
HTML document


add this tag above body tag:



<base href="http://www.MyWebSite.com/">


that will then make all links and images on that site start
there.......unless previously defined.

Example 1:

This example will open a link from your computer to your website by default:
Notice i predefined the http://www. for every link and image.

<html>
<head>
<title>My Web Site</title>
</head>
<base href="http://www.MyWebSite.com/">
<body>
<a href="OurWeb/News/abcFile.htm">My Web Site</a>
</body>
</html>



Example 2:

This example will open a link from your computer to where ever you
determine:
Notice the http://www. in it?

<html>
<head>
<title>My Web Site</title>
</head>
<base href="http://www.MyWebSite.com/">
<body>
<a href=http://www.google.com>Google</a>
</body>
</html>





i dont think i worded this the best, hopefully you get what i mean. LOL.



Jay



<fiefie.ni***@gmail.com> wrote in message
Show quote
news:1156608819.960152.246860@b28g2000cwb.googlegroups.com...
>I would like to save a web page to a file and have the hyperlinks work
> when I bring the file back up. If the web page has a hyperlink like the
> following
> <a href="OurWeb/News/abcFile.htm">, after saving the file and showing
> it on the screen, and you try to click on the link, it will try to go
> to C:\OurWeb\News\abcFile.htm instead of
> www.MyWebSite.com/OurWeb/News/abcFile.htm.
> If I am on the website www.MyWebSite.com, and do "File" - "Save As" and
> under "Save as Type" select "Web Page, complete (*.htm,*.html)", it
> will save the hyperlink as www.MyWebSite.com/OurWeb/News/abcFile.htm.
>
> How can I programmatically do "File" - "Save As" and under "Save as
> Type" select "Web Page, complete (*.htm,*.html)" ? Thank you.
>
> This is how I save the web page:
> WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER,
> "c:\abc.htm", null
>
> OR
>
>   Set fs = CreateObject("Scripting.FileSystemObject")
>   Set filePtr = fs.CreateTextFile("c:\abc.htm", True)
>   filePtr.WriteLine (WebBrowser1.Document.body.innerHTML)
>
Author
26 Aug 2006 7:14 PM
fiefie.niles
Thank you.
The problem is, I am saving the file using either the following method:

WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER,
"c:\abc.htm", null
OR
Set fs = CreateObject("Scripting.FileSystemObject")
Set filePtr = fs.CreateTextFile("c:\abc.htm", True)
filePtr.WriteLine (WebBrowser1.Document.body.innerHTML)

Does it mean, that after I save the file, I need to alter it to include
<base href="http://www.MyWebSite.com/"> ?
Or, is there any way to save it with <base
href="http://www.MyWebSite.com/">
in it ?

Thanks again.


Jay wrote:
Show quote
> Well in the pages. why dont you just set a base "href" at the top of each
> HTML document
>
>
> add this tag above body tag:
>
>
>
> <base href="http://www.MyWebSite.com/">
>
>
> that will then make all links and images on that site start
> there.......unless previously defined.
>
> Example 1:
>
> This example will open a link from your computer to your website by default:
> Notice i predefined the http://www. for every link and image.
>
> <html>
> <head>
> <title>My Web Site</title>
> </head>
> <base href="http://www.MyWebSite.com/">
> <body>
> <a href="OurWeb/News/abcFile.htm">My Web Site</a>
> </body>
> </html>
>
>
>
> Example 2:
>
> This example will open a link from your computer to where ever you
> determine:
> Notice the http://www. in it?
>
> <html>
> <head>
> <title>My Web Site</title>
> </head>
> <base href="http://www.MyWebSite.com/">
> <body>
> <a href=http://www.google.com>Google</a>
> </body>
> </html>
>
>
>
>
>
> i dont think i worded this the best, hopefully you get what i mean. LOL.
>
>
>
> Jay
>
>
>
> <fiefie.ni***@gmail.com> wrote in message
> news:1156608819.960152.246860@b28g2000cwb.googlegroups.com...
> >I would like to save a web page to a file and have the hyperlinks work
> > when I bring the file back up. If the web page has a hyperlink like the
> > following
> > <a href="OurWeb/News/abcFile.htm">, after saving the file and showing
> > it on the screen, and you try to click on the link, it will try to go
> > to C:\OurWeb\News\abcFile.htm instead of
> > www.MyWebSite.com/OurWeb/News/abcFile.htm.
> > If I am on the website www.MyWebSite.com, and do "File" - "Save As" and
> > under "Save as Type" select "Web Page, complete (*.htm,*.html)", it
> > will save the hyperlink as www.MyWebSite.com/OurWeb/News/abcFile.htm.
> >
> > How can I programmatically do "File" - "Save As" and under "Save as
> > Type" select "Web Page, complete (*.htm,*.html)" ? Thank you.
> >
> > This is how I save the web page:
> > WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER,
> > "c:\abc.htm", null
> >
> > OR
> >
> >   Set fs = CreateObject("Scripting.FileSystemObject")
> >   Set filePtr = fs.CreateTextFile("c:\abc.htm", True)
> >   filePtr.WriteLine (WebBrowser1.Document.body.innerHTML)
> >
Author
27 Aug 2006 7:50 AM
Mike Brind
Use this to obtain the content of the web page you are saving:
http://www.aspfaq.com/show.asp?id=2173
and then Scripting.FileSystemObject to write the responsetext to a
file.

--
Mike Brind

fiefie.ni***@gmail.com wrote:
Show quote
> Thank you.
> The problem is, I am saving the file using either the following method:
>
> WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER,
> "c:\abc.htm", null
> OR
> Set fs = CreateObject("Scripting.FileSystemObject")
> Set filePtr = fs.CreateTextFile("c:\abc.htm", True)
> filePtr.WriteLine (WebBrowser1.Document.body.innerHTML)
>
> Does it mean, that after I save the file, I need to alter it to include
> <base href="http://www.MyWebSite.com/"> ?
> Or, is there any way to save it with <base
> href="http://www.MyWebSite.com/">
>  in it ?
>
> Thanks again.
>
>
> Jay wrote:
> > Well in the pages. why dont you just set a base "href" at the top of each
> > HTML document
> >
> >
> > add this tag above body tag:
> >
> >
> >
> > <base href="http://www.MyWebSite.com/">
> >
> >
> > that will then make all links and images on that site start
> > there.......unless previously defined.
> >
> > Example 1:
> >
> > This example will open a link from your computer to your website by default:
> > Notice i predefined the http://www. for every link and image.
> >
> > <html>
> > <head>
> > <title>My Web Site</title>
> > </head>
> > <base href="http://www.MyWebSite.com/">
> > <body>
> > <a href="OurWeb/News/abcFile.htm">My Web Site</a>
> > </body>
> > </html>
> >
> >
> >
> > Example 2:
> >
> > This example will open a link from your computer to where ever you
> > determine:
> > Notice the http://www. in it?
> >
> > <html>
> > <head>
> > <title>My Web Site</title>
> > </head>
> > <base href="http://www.MyWebSite.com/">
> > <body>
> > <a href=http://www.google.com>Google</a>
> > </body>
> > </html>
> >
> >
> >
> >
> >
> > i dont think i worded this the best, hopefully you get what i mean. LOL.
> >
> >
> >
> > Jay
> >
> >
> >
> > <fiefie.ni***@gmail.com> wrote in message
> > news:1156608819.960152.246860@b28g2000cwb.googlegroups.com...
> > >I would like to save a web page to a file and have the hyperlinks work
> > > when I bring the file back up. If the web page has a hyperlink like the
> > > following
> > > <a href="OurWeb/News/abcFile.htm">, after saving the file and showing
> > > it on the screen, and you try to click on the link, it will try to go
> > > to C:\OurWeb\News\abcFile.htm instead of
> > > www.MyWebSite.com/OurWeb/News/abcFile.htm.
> > > If I am on the website www.MyWebSite.com, and do "File" - "Save As" and
> > > under "Save as Type" select "Web Page, complete (*.htm,*.html)", it
> > > will save the hyperlink as www.MyWebSite.com/OurWeb/News/abcFile.htm.
> > >
> > > How can I programmatically do "File" - "Save As" and under "Save as
> > > Type" select "Web Page, complete (*.htm,*.html)" ? Thank you.
> > >
> > > This is how I save the web page:
> > > WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER,
> > > "c:\abc.htm", null
> > >
> > > OR
> > >
> > >   Set fs = CreateObject("Scripting.FileSystemObject")
> > >   Set filePtr = fs.CreateTextFile("c:\abc.htm", True)
> > >   filePtr.WriteLine (WebBrowser1.Document.body.innerHTML)
> > >

AddThis Social Bookmark Button