473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Save a web page - hyperlinks question

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 '06 #1
3 8547
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

<fi**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr 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)

Aug 26 '06 #2
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

<fi**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr 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)
Aug 26 '06 #3
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

fi**********@gmail.com 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

<fi**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr 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)
>
Aug 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: scoop_77 | last post by:
I'm looking for some software that would allow me to point to a folder in Windows Explorer, and have it output an html file with hyperlinks to all of the files within that folder and all of the...
3
by: Aasp | last post by:
Hello! I'm a complete Javascript newbie and my question is surely very naive, but believe me, I've spent this whole day searching thru the net and didn't find any solution to my little problem....
9
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored...
1
by: Robin | last post by:
Hello! I'm having trouble with links and hyperlinks in MS Access 2003 - any help would be great! Question 1! The "insert hyperlink" icon opens a browser window, allows the user to browse...
6
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has...
12
by: =?Utf-8?B?RnJlZU5FYXN5?= | last post by:
Hello, the scenario: There's an ASPX page which shows some text and has three buttons at the bottom: Save, Print and Close. Print and close is done by javascript. But how can I save the page...
17
by: =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= | last post by:
Hello, I have build a website with approximately 30 html-pages. When I search this website in Google, I see the index.html or home.html on this website, but also other html-pages on this...
1
by: Anjan Kumar | last post by:
I have a application which has a masterpage. And in the above out of the contentplace holder there are some asp buttons and in the left side there are some hyperlinks. Now the question is how I can;...
12
by: Frustratee | last post by:
Sorry guys, this is killing me. I have been fighting this issue for several weeks, to no avail. I am exporting the results of a query to an excel sheet, with one of the columns being from a field...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.