Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by StMike38
at 2024-09-05 06:47:17
Point:500 Replies:6 POST_ID:829220USER_ID:12094
Topic:
Hypertext Markup Language (HTML);Miscellaneous Software;Miscellaneous Programming
My program outputs a dynamic HTML page from a server. Is there a way to make the page open at an anchor within the page rather than at the top of the page?
Example: An HTML page is created on the fly with an anchor tag <a id="target"></a> 2/3 of the way down the page. The page is written (as always) to stdout. How do I get that page to open at the target?
With static pages, it is easy -- <a href="www.MyServer.com/MyPage.asp#target">Click here</a>. When writing dynamic pages, how ???????????
Example: An HTML page is created on the fly with an anchor tag <a id="target"></a> 2/3 of the way down the page. The page is written (as always) to stdout. How do I get that page to open at the target?
With static pages, it is easy -- <a href="www.MyServer.com/MyPage.asp#target">Click here</a>. When writing dynamic pages, how ???????????
Expert: paulmacd replied at 2024-09-07 15:53:51
I'm glad the solution works for you, and am very happy to have been of service.
Author: StMike38 replied at 2024-09-06 08:06:19
To paulmacd: Modifying the body tag works both in the server program and in a PC-based CHtmlView equivalent program. In both cases, the page opens very nicely at the anchor point.
Thank you very much for a neat and elegant solution. You have been most helpful.
StMike38
Thank you very much for a neat and elegant solution. You have been most helpful.
StMike38
Accepted Solution
Expert: paulmacd replied at 2024-09-05 09:48:22
500 points EXCELLENT
There's nothing to maintain. As you build the page, write out a body tag that includes an onload event...
<body onload="window.location.hash='anchor';">
...then, wherever you want to page to jump to, insert an anchor tag...
<a name="anchor">
...and you should be all set
<body onload="window.location.hash='anchor';">
...then, wherever you want to page to jump to, insert an anchor tag...
<a name="anchor">
...and you should be all set
Author: StMike38 replied at 2024-09-05 08:48:34
To rwniceing: When creating a dynamic page, there is no one to click a link. The target is not the top; it's well below.
To paulmacd: I have written and am writing (too many tens of thousands of lines of) C++. The problem with Javascript is that I cannot maintain it.
I have implemented a temporary solution -- injecting a link visible near the top of the page, so the user has to click it to be taken to the desired point. If interested, you can see that solution as follows:
[1] Browse to http://www.marpx.com/shake/
[2] Click on "Launch research index"
[3] Enter something in the search box, for example: Ophelia water [without quotes]
[4] Click the "Expand" logo in the lower left.
[5] Note the link "Highlighted result" near the top. Click on it.
[6] You are taken to the result well down the page.
I would prefer to make step 5 unnecessary by having the page open at the paragraph containing water and Ophelia 4 words apart.
StMike38
To paulmacd: I have written and am writing (too many tens of thousands of lines of) C++. The problem with Javascript is that I cannot maintain it.
I have implemented a temporary solution -- injecting a link visible near the top of the page, so the user has to click it to be taken to the desired point. If interested, you can see that solution as follows:
[1] Browse to http://www.marpx.com/shake/
[2] Click on "Launch research index"
[3] Enter something in the search box, for example: Ophelia water [without quotes]
[4] Click the "Expand" logo in the lower left.
[5] Note the link "Highlighted result" near the top. Click on it.
[6] You are taken to the result well down the page.
I would prefer to make step 5 unnecessary by having the page open at the paragraph containing water and Ophelia 4 words apart.
StMike38
Expert: paulmacd replied at 2024-09-05 07:12:52
You could probably inject some javascript to open the page (to the imbedded anchor) once it's been generated. You would need a flag of some sort to make sure the javascript only fired once.
There's also window.location in javascript, which you might be able to use to scroll to an anchor location on the page.
There's also window.location in javascript, which you might be able to use to scroll to an anchor location on the page.
Expert: rwniceing replied at 2024-09-05 07:10:53
Read this anchor tag tutorial link at http://www.w3schools.com/tags/tag_a.asp
and try <a href="www.MyServer.com/MyPage.asp#target" target="_top">Click here</a>
Is it what your need ?
and try <a href="www.MyServer.com/MyPage.asp#target" target="_top">Click here</a>
Is it what your need ?