Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Save a web page - hyperlinks question

Reply
Thread Tools

Save a web page - hyperlinks question

 
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      08-26-2006
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)

 
Reply With Quote
 
 
 
 
Jay
Guest
Posts: n/a
 
      08-26-2006
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



<> wrote in message
news: oups.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)
>



 
Reply With Quote
 
 
 
 
fiefie.niles@gmail.com
Guest
Posts: n/a
 
      08-26-2006
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
>
>
>
> <> wrote in message
> news: oups.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)
> >


 
Reply With Quote
 
Mike Brind
Guest
Posts: n/a
 
      08-27-2006
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

wrote:
> 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
> >
> >
> >
> > <> wrote in message
> > news: oups.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)
> > >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrievel Hyperlinks for a web page in code Enigma Boy ASP .Net 2 08-14-2007 10:56 AM
how to automatically "Save " a page after certain intervals without clicking "Save Page As..." subhadip Java 0 03-28-2007 04:15 PM
ASP read the execl cell's data, web page created from Excel2000 -- Save as web page Michael ASP General 0 08-14-2005 10:10 AM
Save Page As Web Page SMG ASP .Net 3 04-01-2005 02:46 PM
hyperlinks don't appear on Google page. Settings? Bruce Computer Support 1 07-07-2004 07:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57