[l2h] Links with explicit TARGET attributes

Steffen Klupsch Steffen Klupsch <steffen@vlsi.informatik.tu-darmstadt.de>
Fri, 20 Oct 2000 15:05:55 +0200


Ross explained an alternative way to produce links into (other) frames for all
those who use the 'frame' extensions.

I gave it a try - and it works well. 

:-) For everybody else to understand the approach
Ross allowed me to forward his email to the list.


Steffen


Ross Moore wrote:
> 
> > Ross Moore wrote:
> > >
> > > > Steffen Klupsch wrote:
> > > > > \HTMLcode[href=www.vlsi.informatik.tu-darmstadt.de/~steffen/,
> > > > >           target=\_blank]{A}{You may click to see my homepage. }
> 
> There is another way to get the  target  attribute set.
> If you are using the  'frame' extension; e.g.
> 
>         latex2html -html_version 4.0,frame  myfile.tex
> 
> then support for the target is built-in.
> It is handled by a Perl variable  $target  that is set and reset
> according to the frame that needs to be linked-to; e.g.
> for footnotes, Index, navigation etc.
> 
> You can piggy-back onto this mechanism by altering the default
> value of $target, using the \HTMLset command.
> 
> i.e.  \HTMLset{target}{\_blank}
> 
> will give you target="_blank" for ant hyperlinks that are created
> while $target has this value.
> 
> For an example of this in action, see:
> 
>         http://www.iciam.com/
> 
> and find any of the Sponsor sections.
> All the links (e.g. the logo images) jump to sponsor's pages,
> using a new window.
> 
> The code used there, in one particular place, is:
> 
>         \htmlrule[all]{}
>         \HTMLset{target}{\_sponsors}
> 
>         \htmladdnormallink{\ANZIAMlogo[align=RIGHT]}{\ANZIAMurl}
>         \htmladdnormallink{\CMISlogo[align=RIGHT]}{\CMISurl}
> 
>         Support the \htmlref{Sponsors}{Sponsors}:
> 
>         \htmladdnormallink{\AustMSlogo[align=LEFT]}{\AustMSurl}
>         \HTMLset{target}{}
> 
> Note 2 important aspects:
> 
>   1. the $target is reset to '' after the desired use is complete.
> 
>   2. the link generated by \htmlref is unaffected, since this is
>      to an internal part of the document. The internal setting
>      of $target for this link locally overrides the value set manually.
> 
>  and a 3rd, which is far from obvious:
> 
> If you have environments within the region of the document where
> the value of $target is required, then you must use \HTMLsetenv
> instead of \HTMLset ; e.g.
> 
>         \HTMLsetenv{target}{\_sponsors}
>         \begin{center}
>         \htmladdnormallink{\ANZIAMlogo[align=RIGHT]}{\ANZIAMurl}
>         \htmladdnormallink{\CMISlogo[align=RIGHT]}{\CMISurl}
> 
>         Support the \htmlref{Sponsors}{Sponsors}:
> 
>         \end{center}
>         \htmladdnormallink{\AustMSlogo[align=LEFT]}{\AustMSurl}
>         \HTMLsetenv{target}{}
> 
> would use the '_sponsors' frame for the "centered" links,
> but *not* for the 3rd link coming outside the environment.
> This is because the last \HTMLsetenv{target}{} is actually
> evaluated *before* the \htmladdnormallink on the line preceding it.
> 
> LaTeX2HTML evaluates all complete environments and {...} groupings
> before (i.e. unwrapped, or order-insensitive) bare commands.
> In these terms, \HTMLset and \htmladdnormallink are order-insensitive,
> whereas \HTMLsetenv is order-sensitive.
> 
> 
> THis presupposes that you are using the frame.pl extension,
> that redefines how hyperlinks are generated, to include the $target
> variable.
> 
> If you want this feature *without* using frames,
> then copy the appropriate code-blocks from  frame.pl
> into the  .latex2html-init  file, and emulate the rebinding
> that allows this code block to do it's thing.
> (It's quite elementary Perl programming.  :-)