Forum archive 2000-2006

Michael Gage - htmlLink

Michael Gage - htmlLink

by Arnold Pizer -
Number of replies: 0
inactiveTopichtmlLink topic started 9/19/2001; 3:42:55 PM
last post 9/19/2001; 8:17:17 PM
userMichael Gage - htmlLink  blueArrow
9/19/2001; 3:42:55 PM (reads: 2471, responses: 2)

htmlLink

Description
Creates a link to a URL

Syntax

htmlLink($url,$text,$str)

Params

$url is the address of the link -- e.g "http://webwork.math.rochester.edu/".
$text -- the text which is underlined and linked to the url
$str -- is string which can be used to add options to the link construction.

Returns

A string. In TeX mode (hard copy mode) the string contains only the underlined $text and the other parameters are ignored. The other modes return an active link labeled by $text. The $str variable can be used to add options to the link. (<A HREF=\"$url\" $options> $text</A>)

Examples

*htmlLink("http://webwork.math.rochester.edu/docs/docs/pglanguage", "for pg language help")


*htmlLink("http://webwork.math.rochester.edu/docs/docs/pglanguage", "for pg language help", "TARGET=~~"new_window~~"");

(recall that ~~ is the escape symbol for .pg files, not as is used in .pl files and Perl generally.)

*htmlLink("http://webwork.math.rochester.edu/docs/docs/pglanguage", "for pg language help", 'TARGET= "new_window"');
(This works since no variable interpolation is needed within the single quotes.)

*htmlLink("http://webwork.math.rochester.edu/docs/docs/pglanguage", "for pg language help", q{TARGET= "new_window"});
(This also works using one of the many "quoting mechanisms" available in Perl)

*htmlLink("http://webwork.math.rochester.edu/docs/docs/pglanguage", "for pg language help", "TARGET= new_window");
(This also works, usually, but it is slightly questionable HTML since the value of TARGET is not in quotes.)

 

<| Post or View Comments |>


userymarkov - Re: htmlLink  blueArrow
9/19/2001; 4:36:12 PM (reads: 1992, responses: 1)
Thank you very much for the quick reply. It seems to me that for example "TARGET=qq/new_window/" is slightly less dependent on the Perl instalation than the double quotation marks, which caused error on my system. Thanks again,

Yavor

<| Post or View Comments |>


userMichael Gage - Re: htmlLink  blueArrow
9/19/2001; 8:17:17 PM (reads: 2398, responses: 0)
Hi Yavor,

You're welcome and I'm sorry that I had to hack out the reply quite so quickly.

The difficulty you had is not with your installation, but because I should have used ~~ instead of \ to escape the quotes.

You must use \ in .pl files (and Perl in general), but in .pg files you must use ~~ as an escape character because \ has been reserved for use in TeX phrases.

Using the Perl quoting method as qq/TARGET="new_window"/ is easier to read than escaping the quotes as you have observed. q/TARGET="new_window"/ and 'TARGET="new_window"' also work -- (hey, it's perl and there is always more than one right way to do things. :-) ) "TARGET=new_window" also works, but it is less than perfect HTML since the value of TARGET is supposed to be quoted, so I don't recommend that. "TARGET=qq/new_window/" works for the same reason but actually opens a window named qq/new_window/ which is probably not what you were expecting.

Bottom line: q/TARGET="new_window"/ is probably the best way to do this.

Thanks much for bringing this to our attention.

-- Mike

<| Post or View Comments |>