Home > Archive > Tcl > June 2007 > TkHTML3 and Anchors
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
TkHTML3 and Anchors
|
|
| skuhagen@web.de 2007-06-08, 10:11 pm |
| Hello
Another TkHTML3 Question... (is there anybody out there, using TkHTML?
- Since I only got a single answer for TkHTML2 (!) to my last TkHTML3
Question, I'm wondering, if this is dead software or not...)
Anyway: I managed to load and display html-documents, links work,
images also (averything only local), but I can't figure out how to
load a document and then navigate inside the document with anchors.
For example if I have "file:///tmp/theFile.html#theAnchor", I can load
theFile.html, but I don't know, how to scroll to #theAnchor. I can't
find any info about anchors or other specific elements in the
document... Any suggestions?
TIA, Regards
Stephan
| |
| Eric Hassold 2007-06-08, 10:11 pm |
| Hi,
skuhagen@web.de wrote :
> Hello
>
> Another TkHTML3 Question... (is there anybody out there, using TkHTML?
> - Since I only got a single answer for TkHTML2 (!) to my last TkHTML3
> Question, I'm wondering, if this is dead software or not...)
Dead?? When looking at impressive job Dan Kennedy is doing on it
http://tkhtml.tcl.tk/cvstrac/timeline
I have more the feeling this is a very promising software, with already
great capabilities. It is still young (alpha stage, API is changing),
and price for its powerful capabilities is sometime some kind of
complexity, so this may explain why questions don't get answers very
easily. It's difficult to get in because it is in its infancy, not
because it is dying.
>
> Anyway: I managed to load and display html-documents, links work,
> images also (averything only local), but I can't figure out how to
> load a document and then navigate inside the document with anchors.
> For example if I have "file:///tmp/theFile.html#theAnchor", I can load
> theFile.html, but I don't know, how to scroll to #theAnchor. I can't
> find any info about anchors or other specific elements in the
> document... Any suggestions?
hv3 code (available from Tkhtml3 sources) provides good recipes, when
documentation is missing. Especially, "goto_fragment" method in hv3.tcl
might interest you:
method goto_fragment {} {
set fragment [$myUri cget -fragment]
if {$fragment ne ""} {
set selector [format {[name="%s"]} $fragment]
set goto_node [lindex [$myHtml search $selector] 0]
# If there was no node with the name attribute set to the fragment,
# search for a node with the id attribute set to the fragment.
if {$goto_node eq ""} {
set selector [format {[id="%s"]} $fragment]
set goto_node [lindex [$myHtml search $selector] 0]
}
if {$goto_node ne ""} {
$myHtml yview $goto_node
}
}
}
So, I hope this solves your problem:
set fragment "myAnchor"
set selector [format {[name="%s"]} $fragment]
set node [lindex [$htmlwidget search $selector] 0]
if {$node ne ""} {
$htmlwidget yview $node
}
Eric
-----
Eric Hassold
Evolane - http://www.evolane.com/
| |
|
|
| skuhagen@web.de 2007-06-11, 8:08 am |
| Hello
Eric Hassold wrote:
> Dead?? When looking at impressive job Dan Kennedy is doing on it
> http://tkhtml.tcl.tk/cvstrac/timeline
Ah, I wasn't aware of this. The last thing I found was the
announcement of the alpha version last year and since not much
diskussion about it. Thanks for the link.
> set fragment "myAnchor"
> set selector [format {[name="%s"]} $fragment]
> set node [lindex [$htmlwidget search $selector] 0]
> if {$node ne ""} {
> $htmlwidget yview $node
> }
That was very helpful, thank you very much.
Stephan
|
|
|
|
|