Named anchor in html()?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Named anchor in html()?

Post by highend »

Normally you would use e.g.:

Code: Select all

    <body>
        <div>
            <a href="#fun">Go to fun</a>

            <br><br><br><br><br><br><br>
            <br><br><br><br><br><br><br>
            <br><br><br><br><br><br><br>

            <h2 id="fun">Here is the target</h2>
        </div>
    </body>
But hovering over the Go to fun link already reveals that it will open

Code: Select all

about:blank#fun
Doesn't work as well:

Code: Select all

<a href="self:#fun">Go to fun</a>
How to proceed?
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Named anchor in html()?

Post by highend »

Not possible?
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Named anchor in html()?

Post by bdeshi »

html()/vb ie control opens about:blank and adds html content into it. So anchors refer to about:blank. I myself have no idea how to work around that.
Meanwhile, you can write the html to a file and display it, or use JS.

Code: Select all

  $html = writefile("<xydata>\tmp\html", <html ...>);
  html("file:///<xydata>\tmp\html");
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 60561
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Named anchor in html()?

Post by admin »

Works here. What's your context?

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Named anchor in html()?

Post by highend »

@Sammay
I'd like to avoid to write a html file every time.
Any hints how a JS should look like? The entries in the <body>...</body> are created dynamically...

@Don
E.g.:

Code: Select all


    $html = <<<>>>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <style>
            table {
    table-layout: fixed;
    width: 820 px;
    border-collapse: collapse;
}

td {
    width: 107 px;
    padding: 2px 0px 2px 5px;
}

td.nav {
    width: 10 px;
    color: #FF4500;
    padding: 0px;
    font-size: 11 px;
}

a {
    cursor: pointer;
    height: 15px;
    text-align: left;
    text-decoration: none;
    padding: 2px 0px;
    font-family: Courier new;
}

a.nav:link, a.nav:visited {
    color: #FF4500;
    font-size: 16 px;
}

a.nav:hover, a.nav:active {
    color: white;
    background-color: #FF4500;
}

a.lnk:link, a.lnk:visited {
    color: blue;
    font-size: 11 px;
}

a.lnk:hover, a.lnk:active {
    background-color: #DCDCDC; // Gainsboro
}
        </style>
    </head>
    <body>
        <div style="position: absolute;top: 10px;">
            <a href="#A" class="nav">A</a>
<a href="#B" class="nav">B</a>
<a href="#C" class="nav">C</a>
<a href="#D" class="nav">D</a>
<a href="#E" class="nav">E</a>
<a href="#F" class="nav">F</a>
<a href="#G" class="nav">G</a>
<a href="#H" class="nav">H</a>
<a href="#I" class="nav">I</a>
<a href="#L" class="nav">L</a>
<a href="#M" class="nav">M</a>
<a href="#O" class="nav">O</a>
<a href="#P" class="nav">P</a>
<a href="#R" class="nav">R</a>
<a href="#S" class="nav">S</a>
<a href="#T" class="nav">T</a>
<a href="#V" class="nav">V</a>
<a href="#W" class="nav">W</a>

        </div>
        <div style="position: absolute;top: 40px;">
            <table>
                <tr><td class="nav"><a name="A">A</a></td><td><a href="xys:C:\Windows\ADFS" class="lnk" style="color:$color">ADFS</a></td><td><a href="xys:C:\Windows\appcompat" class="lnk" style="color:$color">appcompat</a></td><td><a href="xys:C:\Windows\AppPatch" class="lnk" style="color:$color">AppPatch</a></td><td><a href="xys:C:\Windows\AppReadiness" class="lnk" style="color:$color">AppReadiness</a></td><td><a href="xys:C:\Windows\assembly" class="lnk" style="color:$color">assembly</a></td></tr>
<tr><td class="nav"><a name="B">B</a></td><td><a href="xys:C:\Windows\bcastdvr" class="lnk" style="color:$color">bcastdvr</a></td><td><a href="xys:C:\Windows\Boot" class="lnk" style="color:$color">Boot</a></td><td><a href="xys:C:\Windows\Branding" class="lnk" style="color:$color">Branding</a></td></tr>
<tr><td class="nav"><a name="C">C</a></td><td><a href="xys:C:\Windows\CbsTemp" class="lnk" style="color:$color">CbsTemp</a></td><td><a href="xys:C:\Windows\Cursors" class="lnk" style="color:$color">Cursors</a></td></tr>
<tr><td class="nav"><a name="D">D</a></td><td><a href="xys:C:\Windows\debug" class="lnk" style="color:$color">debug</a></td><td><a href="xys:C:\Windows\de-DE" class="lnk" style="color:$color">de-DE</a></td><td><a href="xys:C:\Windows\diagnostics" class="lnk" style="color:$color">diagnostics</a></td><td><a href="xys:C:\Windows\DigitalLocker" class="lnk" style="color:$color">DigitalLocker</a></td><td><a href="xys:C:\Windows\Downloaded Program Files" class="lnk" style="color:$color">Downlo...Files</a></td><td><a href="xys:C:\Windows\drivers" class="lnk" style="color:$color">drivers</a></td></tr>
<tr><td class="nav"><a name="E">E</a></td><td><a href="xys:C:\Windows\ELAMBKUP" class="lnk" style="color:$color">ELAMBKUP</a></td><td><a href="xys:C:\Windows\en-US" class="lnk" style="color:$color">en-US</a></td></tr>
<tr><td class="nav"><a name="F">F</a></td><td><a href="xys:C:\Windows\Fonts" class="lnk" style="color:$color">Fonts</a></td></tr>
<tr><td class="nav"><a name="G">G</a></td><td><a href="xys:C:\Windows\GameBarPresenceWriter" class="lnk" style="color:$color">GameBa...riter</a></td><td><a href="xys:C:\Windows\Globalization" class="lnk" style="color:$color">Globalization</a></td></tr>
<tr><td class="nav"><a name="H">H</a></td><td><a href="xys:C:\Windows\Help" class="lnk" style="color:$color">Help</a></td></tr>
<tr><td class="nav"><a name="I">I</a></td><td><a href="xys:C:\Windows\IME" class="lnk" style="color:$color">IME</a></td><td><a href="xys:C:\Windows\ImmersiveControlPanel" class="lnk" style="color:$color">Immers...Panel</a></td><td><a href="xys:C:\Windows\INF" class="lnk" style="color:$color">INF</a></td><td><a href="xys:C:\Windows\InfusedApps" class="lnk" style="color:$color">InfusedApps</a></td><td><a href="xys:C:\Windows\InputMethod" class="lnk" style="color:$color">InputMethod</a></td><td><a href="xys:C:\Windows\Installer" class="lnk" style="color:$color">Installer</a></td></tr>
<tr><td class="nav"><a name="L">L</a></td><td><a href="xys:C:\Windows\L2Schemas" class="lnk" style="color:$color">L2Schemas</a></td><td><a href="xys:C:\Windows\LiveKernelReports" class="lnk" style="color:$color">LiveKe...ports</a></td><td><a href="xys:C:\Windows\Logs" class="lnk" style="color:$color">Logs</a></td></tr>
<tr><td class="nav"><a name="M">M</a></td><td><a href="xys:C:\Windows\Media" class="lnk" style="color:$color">Media</a></td><td><a href="xys:C:\Windows\Microsoft.NET" class="lnk" style="color:$color">Microsoft.NET</a></td><td><a href="xys:C:\Windows\Migration" class="lnk" style="color:$color">Migration</a></td><td><a href="xys:C:\Windows\MiracastView" class="lnk" style="color:$color">MiracastView</a></td><td><a href="xys:C:\Windows\ModemLogs" class="lnk" style="color:$color">ModemLogs</a></td></tr>
<tr><td class="nav"><a name="O">O</a></td><td><a href="xys:C:\Windows\Offline Web Pages" class="lnk" style="color:$color">Offlin...Pages</a></td></tr>
<tr><td class="nav"><a name="P">P</a></td><td><a href="xys:C:\Windows\Panther" class="lnk" style="color:$color">Panther</a></td><td><a href="xys:C:\Windows\Performance" class="lnk" style="color:$color">Performance</a></td><td><a href="xys:C:\Windows\PLA" class="lnk" style="color:$color">PLA</a></td><td><a href="xys:C:\Windows\PolicyDefinitions" class="lnk" style="color:$color">Policy...tions</a></td><td><a href="xys:C:\Windows\PrintDialog" class="lnk" style="color:$color">PrintDialog</a></td><td><a href="xys:C:\Windows\Provisioning" class="lnk" style="color:$color">Provisioning</a></td></tr>
<tr><td class="nav"><a name="R">R</a></td><td><a href="xys:C:\Windows\Registration" class="lnk" style="color:$color">Registration</a></td><td><a href="xys:C:\Windows\RemotePackages" class="lnk" style="color:$color">RemotePackages</a></td><td><a href="xys:C:\Windows\rescache" class="lnk" style="color:$color">rescache</a></td><td><a href="xys:C:\Windows\Resources" class="lnk" style="color:$color">Resources</a></td></tr>
<tr><td class="nav"><a name="S">S</a></td><td><a href="xys:C:\Windows\SchCache" class="lnk" style="color:$color">SchCache</a></td><td><a href="xys:C:\Windows\schemas" class="lnk" style="color:$color">schemas</a></td><td><a href="xys:C:\Windows\security" class="lnk" style="color:$color">security</a></td><td><a href="xys:C:\Windows\ServiceProfiles" class="lnk" style="color:$color">ServiceProfiles</a></td><td><a href="xys:C:\Windows\servicing" class="lnk" style="color:$color">servicing</a></td><td><a href="xys:C:\Windows\Setup" class="lnk" style="color:$color">Setup</a></td><td><a href="xys:C:\Windows\ShellExperiences" class="lnk" style="color:$color">ShellE...ences</a></td></tr>
<tr><td></td><td><a href="xys:C:\Windows\SKB" class="lnk" style="color:$color">SKB</a></td><td><a href="xys:C:\Windows\SoftwareDistribution" class="lnk" style="color:$color">Softwa...ution</a></td><td><a href="xys:C:\Windows\Speech" class="lnk" style="color:$color">Speech</a></td><td><a href="xys:C:\Windows\Speech_OneCore" class="lnk" style="color:$color">Speech_OneCore</a></td><td><a href="xys:C:\Windows\System" class="lnk" style="color:$color">System</a></td><td><a href="xys:C:\Windows\System32" class="lnk" style="color:$color">System32</a></td><td><a href="xys:C:\Windows\SystemApps" class="lnk" style="color:$color">SystemApps</a></td></tr>
<tr><td></td><td><a href="xys:C:\Windows\SystemResources" class="lnk" style="color:$color">SystemResources</a></td><td><a href="xys:C:\Windows\SysWOW64" class="lnk" style="color:$color">SysWOW64</a></td></tr>
<tr><td class="nav"><a name="T">T</a></td><td><a href="xys:C:\Windows\TAPI" class="lnk" style="color:$color">TAPI</a></td><td><a href="xys:C:\Windows\Tasks" class="lnk" style="color:$color">Tasks</a></td><td><a href="xys:C:\Windows\Temp" class="lnk" style="color:$color">Temp</a></td><td><a href="xys:C:\Windows\tracing" class="lnk" style="color:$color">tracing</a></td><td><a href="xys:C:\Windows\twain_32" class="lnk" style="color:$color">twain_32</a></td></tr>
<tr><td class="nav"><a name="V">V</a></td><td><a href="xys:C:\Windows\Vss" class="lnk" style="color:$color">Vss</a></td></tr>
<tr><td class="nav"><a name="W">W</a></td><td><a href="xys:C:\Windows\Web" class="lnk" style="color:$color">Web</a></td><td><a href="xys:C:\Windows\WinSxS" class="lnk" style="color:$color">WinSxS</a></td></tr>

            </table>
        </div>
    </body>
</html>
>>>;

    echo html($html, 900, 800, "Click on the destination folder link...");
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60561
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Named anchor in html()?

Post by admin »

Ah, ok, problem confirmed. Have no solution.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Named anchor in html()?

Post by bdeshi »

highend wrote:@Sammay
I'd like to avoid to write a html file every time.
Any hints how a JS should look like? The entries in the <body>...</body> are created dynamically...
Sure. Here's one method.

Set up anchor links like this template, $id being the name of the id.

Code: Select all

<a href="#$id" onclick='go("$id");return false'>Go to $id</a>
...
<h2 id="$id">Here is the $id target</h2>
(`return false` is needed to stop loading the original link to about:blank. Or you can skip the href attr and use css to make the <a> element look like a link.)
And here's the function:

Code: Select all

<script>
  function go(id){ document.getElementById(id).scrollIntoView(true); };
</script>
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Named anchor in html()?

Post by highend »

Thanks Sammay!

Unfortunately it still does only work when I save the html code into a file and call html() with that.
And inside a browser it works fine as well ofc. But calling html() directly on the generated code
doesn't work. At least here. Can you try it, please?
testhtmlform.zip
(1.9 KiB) Downloaded 25 times
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Named anchor in html()?

Post by bdeshi »

Well, it works here. clicked on B, scrolled to B, and so on.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Named anchor in html()?

Post by highend »

Okidoki, I'll figure it out why it isn't working here (must be IE related).

Thanks
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: Named anchor in html()?

Post by klownboy »

Works fine for me as well with Windows 10 Pro x64 Creators Update.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Post Reply