Save a web page - hyperlinks question

Discussion in 'ASP General' started by fiefie.niles@gmail.com, Aug 26, 2006.

  1. Guest

    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)
     
    , Aug 26, 2006
    #1
    1. Advertising

  2. Jay Guest

    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:...
    >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)
    >
     
    Jay, Aug 26, 2006
    #2
    1. Advertising

  3. Guest

    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:...
    > >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)
    > >
     
    , Aug 26, 2006
    #3
  4. Mike Brind Guest

    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:...
    > > >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)
    > > >
     
    Mike Brind, Aug 27, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. subhadip
    Replies:
    0
    Views:
    676
    subhadip
    Mar 28, 2007
  2. Enigma Boy
    Replies:
    2
    Views:
    341
    Jesse Houwing
    Aug 14, 2007
  3. JPElectron

    redisplay a page without any of the hyperlinks

    JPElectron, May 2, 2004, in forum: ASP General
    Replies:
    4
    Views:
    162
    JPElectron
    May 2, 2004
  4. Michael
    Replies:
    0
    Views:
    185
    Michael
    Aug 14, 2005
  5. Dave Marden
    Replies:
    3
    Views:
    138
    ThatsIT.com.au
    Jan 21, 2007
Loading...

Share This Page