1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
|
<!doctype html public "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Clickable Images and Imagemap files on the WN Server</title>
<link rev="made" href="mailto:john@math.nwu.edu">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="last-modified" content="Fri, 09 Oct 1998 18:18:09 GMT">
<meta http-equiv="keywords" content="WN image maps">
</head>
<body bgcolor="#FFFFFF">
<p>
<a href="http://hopf.math.nwu.edu/"><img
src="images/powered.jpg"
border="0"
width="190"
height="41"
align="right"
alt="WN home page"
></a>
</p>
<strong>Version 2.0.3</strong>
<br>
<!-- pnuts --> <a href="module.html">[Previous]</a> <a href="cgi.html">[Next]</a> <a href="manual.html">[Up]</a> <a href="manual.html">[Top]</a> <a href="dosearch.html">[Search]</a> <a href="docindex.html">[Index]</a>
<br clear="right">
<hr size="4">
<!-- #start -->
<h2 align="center">Clickable Images and Imagemap files on the <em>WN</em>
Server</h2>
<hr size="4">
<p>
As of version 1.07 the <em>WN</em> server does not require the <a
href="http://hoohoo.ncsa.uiuc.edu/docs/tutorials/imagemap.txt">NCSA
C <code>imagemap.c</code> program</a> to support clickable images. This
functionality is now built into the server. Try clicking on this image
for an example.
</p>
<center>
<a href="examples/shape.map"><img src="examples/shape.gif" alt="imagemap"
width="245" height="164" ismap></a>
</center>
<p>
Clickable images like this make use of a "map file" telling the server
which coordinates in the image correspond to which document. The format
of this file <a href="#map_format">(described below)</a> is the same as
that used with the <a
href="http://hoohoo.ncsa.uiuc.edu/docs/tutorials/imagemapping.html">NCSA
imagemap program</a> (with a few minor enhancements).
</p>
<h3>15.1 <a name="howto">The Steps in Setting up a Clickable Image</a></h3>
<h4>15.1.1 <a name="howto.create_image">Create an Image</a></h4>
<p>
There are a number of image creation and editing programs that can be
used. One (which I have not tried) is <a
href="http://www.danbbs.dk/~torsten/xpaint/index.html">xpaint</a>. The
image file must be in <code>gif</code>, <code>jpeg</code> or
<code>xbm</code> format.
</p>
<h4>15.1.2 <a name="howto.create_map">Create a Map File</a></h4>
<p>
This is a file containing lines specifying regions in the image and the
URL to which the client should be directed after clicking in one of these
regions. The format of this file is <a href="#map_format">described
below</a> in detail, but roughly a line contains the name of a shape
(like a rectangle) the URL to go to and the pixel coordinates necessary
to specify the rectangle.
</p>
<p>
There is a commercial program called <a
href="http://www.boutell.com/mapedit/">mapedit</a> and a free <a
href="http://www.tclconsortium.org/">tcl/tk</a> program <a
href="http://www.seqnet.dl.ac.uk/CBMT/mapmarker/HOME.html">mapmarker</a>
(neither of which I have used) that are designed to automate this task.
</p>
<h4>15.1.3 <a name="howto.install">Install the Image and Map File on Your
Server</a></h4>
<p>
In the index file for the directory containing the image (let's call it
<code>image.gif</code>) put the lines:
</p>
<blockquote>
<code>
<a href="appendixB.html#fdir.file">File=</a>image.gif
<br>
<br>
<a href="appendixB.html#fdir.file">File=</a>image.map
<br>
<a
href="appendixB.html#fdir.attributes.imagemap">Attributes=imagemap</a>
</code>
</blockquote>
<p>
If your imagemap file redirects the client to other documents on your
server make sure they are also installed. Run <a
href="index_desc.html#wndex"><code>wndex</code></a> where necessary to
update your <code>index.cache</code>.
</p>
<blockquote>
<em>Note:</em> A file named <code>foo.map</code> (i.e. with suffix
"<code>.map</code>") will automatically be considered to have "<code><a
href="appendixB.html#fdir.attributes.imagemap">Attributes=imagemap</a></code>"
set when <a href="index_desc.html#wndex"><code>wndex</code></a> is run
unless a "<code><a
href="appendixB.html#fdir.content-type">Content-type=</a>something</code>"
line is supplied for it.
</blockquote>
<p>
This will also work if the "<code><a
href="appendixB.html#ddir.attributes.serveall">Attributes=serveall</a></code>"
directive is specified for this directory and there is no entry in the <a
href="index_desc.html#index"><code>index</code></a> file for
<code>foo.map</code>. But it is necessary to run <a
href="index_desc.html#wndex"><code>wndex</code></a> since the server will
not recognize <code>foo.map</code> as an <code>imagemap</code> file if <a
href="index_desc.html#wndex"><code>wndex</code></a> has not been run on
the directory containing it.
</p>
<h4>15.1.4 <a name="howto.link">Put a Link to Your Image Map in Your HTML
Document</a></h4>
<p>
In the HTML file which you want to contain the clickable image must put a
link to it which looks like:
</p>
<blockquote>
<code>
<a href="image.map">
<br>
<img src="image.gif" ismap>
<br>
</a>
<br>
</code>
</blockquote>
<p>
assuming that "<code>image.map</code>", "<code>image.gif</code>" and the
file containing this link are all in the same directory.
</p>
<h3>15.2 <a name="map_format">The Format of an Imagemap File</a></h3>
<p>
An imagemap file is a plain text file consisting of lines, each of which
tells the server what to do if a user clicks in a certain region. You
will need to know the dimensions of your image and you will have to have
a way of reading the coordinates of points on your image when you click
on it. I use the program <a href="http://www.trilon.com/xv/">xv</a> to
determine the coordinates.
</p>
<p>
A <a href="examples/ismap.html">complete functioning example</a> of
imagemap use, illustrating all the methods is included with the
<em>WN</em> distribution.
</p>
<p>
An imagemap can contain comments which are lines starting with the
character '<code>#</code>'. These lines are ignored by the server, as
are lines which are blank.
</p>
<p>
All other lines must start with one of the imagemap "method" keywords:
<code>default</code>, <code>rect</code>, <code>circle</code>,
<code>poly</code>, <code> </code> or <code>point</code>. Here is a
description of each type of method line.
</p>
<h4>15.2.1 <a name="map_format.default"><code>default</code>
keyword</a></h4>
<p>
This line contains only the keyword "<code>default</code>" followed by
white space and the URL to be referenced if none of the other other
regions is selected. An example is:
</p>
<blockquote>
<code>
default http://webhost/dir/default.html
</code>
</blockquote>
<h4>15.2.2 <a name="map_format.rect"><code>rect</code> keyword</a></h4>
<p>
This line contains the keyword "<code>rect</code>" followed by white
space and the URL to be referenced and more white space followed by the
coordinates of the upper left and lower right corners of the rectangle.
When the coordinates of the clicked on point lie within the rectangle
specified by these coordinates the given URL will be referenced. An
example is:
</p>
<blockquote>
<code>
rect http://webhost/dir/rect.html 20,20 70,100
</code>
</blockquote>
<p>
Note the coordinates of the rectangle corners consist of the X coordinate
(two numbers separated by a comma) followed by whitespace followed by the
Y coordinate (two more numbers separated by a comma). This URL will be
returned if the clicked on point lies in the rectangle with opposite
corners <code>(20,20)</code> and <code>(70,10)</code>. In screen
coordinates (as opposed to the Cartesian plane) these are the upper left
and lower right corners respectively.
</p>
<h4>15.2.3 <a name="map_format.circle"><code>circle</code> keyword</a></h4>
<p>
This line contains the keyword "<code>circle</code>" followed by white
space and the URL to be referenced and more white space followed by the
coordinates of the center of the circle and the coordinates of a point on
the circle. When the coordinates of the clicked on point lie within the
circle specified by these coordinates the given URL will be referenced.
An example is:
</p>
<blockquote>
<code>
circle http://webhost/dir/circle.html 70,70 70,100
</code>
</blockquote>
<p>
This URL will be returned if the clicked on point lies in the the circle
with center at <code>(70,70)</code> and radius <code>30</code> (i.e. the
circle with center <code>(70,70)</code> containing the point
<code>(70,100)</code>).
</p>
<h4>15.2.4 <a name="map_format.poly"><code>poly</code> keyword</a></h4>
<p>
This line contains the keyword "<code>poly</code>" followed by white
space and the URL to be referenced and more white space followed by the a
sequence of coordinates of the vertices of a polygon, in order. The
polygon so determined is the one you would obtain by connecting each of
the vertices in order with a straight line and then connecting the last
vertex to the first. The polygon need not be convex.
</p>
<blockquote>
<em>Technical note:</em> The curve formed in this way may cross itself --
a point will be considered inside if the winding number of the curve
around the point is non-zero.
</blockquote>
<p>
An example is:
</p>
<blockquote>
<code>
poly http://webhost/dir/triangle.html 10,20 70,100 5,150
</code>
</blockquote>
<p>
This URL will be returned if the clicked on point lies in the triangle
with vertices <code>(10,20)</code>, <code>(70,100)</code> and
<code>(5,150)</code>.
</p>
<h4>15.2.5 <a name="map_format.point"><code>point</code> keyword</a></h4>
<p>
This line contains the keyword "<code>point</code>" followed by white
space and the URL to be referenced and more white space followed by the a
sequence of coordinates of one or more points in the the image. This
method replaces the <code><a
href="#map_format.default">default</a></code>. The default URL
referenced is the one associated with the point in a "point method" line
which is closest to the clicked location. An example is:
</p>
<blockquote>
<code>
point http://webhost/dir/point1.html 10,20 70,100
<br>
point http://webhost/dir/point2.html 100,110 80,5
</code>
</blockquote>
<p>
If no other method has returned a URL then the returned URL will be to
<code>point1.html</code> or <code>point2.html</code> depending on whether
the clicked on location is closer to one of the points
<code>(10.20)</code> or <code>(70,100)</code> or to one of the points
<code>(100,110)</code> or <code>(80,5)</code>.
</p>
<blockquote>
<em>Note:</em> Allowing multiple points on a single point method line is
a <em>WN</em> enhancement and will not be portable to other imagemap
programs.
</blockquote>
<h4>15.2.6 <a name="map_format.point"><code>nocoords</code>
keyword</a></h4>
<p>
This line contains the keyword "<code>nocoords</code>" followed by white
space and the URL to be referenced when a user with a non-graphical
browser selects the the substitute text for the image. More precisely,
if any browser makes a request for the document and does not include the
X and Y coordinates of the point clicked on in the image then this URL
will be referenced. An example is:
</p>
<blockquote>
<code>
nocoords http://webhost/dir/message.txt
</code>
</blockquote>
<blockquote>
<em>Note:</em> The <code>nocoords</code> keyword and functionality is a
<em>WN</em> enhancement and will not be portable to other imagemap
programs.
</blockquote>
<h3>15.3 <a name="url">The URL Format in an Imagemap File</a></h3>
<p>
The <a href="http://linux-howto.com/rfc/rfc1500-1999/rfc1738.txt">URL</a>
in the lines listed above can be in one of the following three forms:
</p>
<blockquote>
<code>
http://remote_host/dir/rect.html
<br>
/dir/rect.html
<br>
rect.html
</code>
</blockquote>
<p>
Here are the differences. The first,
"<code>http://remote_host/dir/rect.html</code>" is primarily used to link
to a document on a remote host. On seeing this the server sends an <a
href="http://www.w3c.org/Protocols/">HTTP/1.1</a> redirect to the client
causing the client to automatically access this URL.
</p>
<p>
The use of "<code>/dir/rect.html</code>" is equivalent to
"<code>http://local_host/dir/rect.html</code>". Any URL specified in a
method line which begins with a '<code>/</code>' is assumed to be on the
local local host and the path is assumed relative to the <em>WN</em> root
directory. An <a href="http://www.w3c.org/Protocols/">HTTP/1.1</a>
redirect is sent because simply sending the file would confuse the client
(it would think that the document <code>rect.html</code> is in the same
directory as the imagemap file which might not be true in which case
relative URLs would fail to work).
</p>
<blockquote>
<em>Warning:</em> The <em>WN</em> root directory is changed by use of
<code>http://host/~user/</code> type URLs.
</blockquote>
<p>
The use of "<code>rect.html</code>" or anything which does not contain
'<code>:/</code>' (i.e. which does not start with <code>http://...</code>
or <code>ftp://...</code>) and does not start with '<code>/</code>'
causes the server to assume that the document is relative to the
directory containing the imagemap. In this case the server will
immediately serve that document with no redirection. This is the most
efficient way to set up an imagemap, but it requires that the response
files like "<code>rect.html</code>" be in the same directory as the
imagemap file. There is one exception to this. If the relative URL
contains a '<code>#</code>' the server prepends the appropriate path to
the URL and sends an <a href="http://www.w3c.org/Protocols/">HTTP/1.1</a>
redirect to the client. This is necessary for the client to be able to
handle the "name" anchor indicated by the '<code>#</code>'.
</p>
<blockquote>
<em>Note:</em> Allowing relative URLs of this type is a <em>WN</em>
enhancement and will not be portable to imagemap programs run on other
servers. Also note that using a relative URL like
"<code>dir/rect.html</code>" referring to a document in a subdirectory
can confuse a browser about the location of documents referred to in
"<code>rect.html</code>". For this reason it should only be used when
the document is not an HTML document or contains a
<code><base></code> tag specifying its location.
</blockquote>
<p>
There is one special URL which may be used in map files, namely
<code><null></code>. It has the effect of not sending a redirect
or a document to the client but instead sending a header with status 204.
This instructs the client to do nothing and in particular not to reload
or alter the document it is displaying. For example, the line:
</p>
<blockquote>
<code>
default <null>
</code>
</blockquote>
<p>
in a map file will have the effect of making clicks in the default area
behave as if the click had been somewhere outside the image, i.e.
nothing will happen.
</p>
<blockquote>
<em>Note:</em> the <code><null></code> URL is a <em>WN</em>
enhancement and will not be portable to imagemap programs run on other
servers.
</blockquote>
<!-- #end -->
<hr size="4">
<address>
<em>WN</em> version 2.0.3
<br>
Copyright © 1998 <a href="mailto:john@math.nwu.edu">John Franks
<john@math.nwu.edu></a>
<br>
licensed under the <a href="http://www.opencontent.org/opl.html">
OpenContent Public License</a>
<br>
last-modified: Fri, 09 Oct 1998 18:18:09 GMT
</address>
<!-- pnuts --> <a href="module.html">[Previous]</a> <a href="cgi.html">[Next]</a> <a href="manual.html">[Up]</a> <a href="manual.html">[Top]</a> <a href="dosearch.html">[Search]</a> <a href="docindex.html">[Index]</a>
</body>
</html>
|