Bonjour à tous
Qui peut m'expliquer à quoi sert le "return false" dans les href, ex : <a href="#" onClick="swapLayers('lyr1'); return false">- Layer 1 -</a>
Et en général à quoi sert-il ?
Merci d'avance![]()
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Showing and Hiding Layers</title> <STYLE TYPE="text/css"> body {font-family: Verdana, arial, helvetica, sans-serif;font-size:12px; margin:20px; padding:0;} h2 { font-size:14px; } a:link { color:#33c; } a:visited { color:#33c; } #lyr1, #lyr2, #lyr3 { position:absolute; visibility:hidden; left:20px; top:60px; width:400px; z-index:100; } </STYLE> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> // onresize for ns4 var origWidth, origHeight; if (document.layers) { origWidth = window.innerWidth; origHeight = window.innerHeight; window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); } } var lay_encours; // holds id of currently visible layer function swapLayers(id) { if (lay_encours) hideLayer(lay_encours); showLayer(id); lay_encours = id; } function showLayer(id) { var lyr = getElemRefs(id); if (lyr && lyr.css) lyr.css.visibility = "visible"; } function hideLayer(id) { var lyr = getElemRefs(id); if (lyr && lyr.css) lyr.css.visibility = "hidden"; } function getElemRefs(id) { var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null; if (el) el.css = (el.style)? el.style: el; return el; } </SCRIPT> </head> <body onload="swapLayers('lyr1');"> <p> <a href="#" onClick="swapLayers('lyr1'); return false">- Layer 1 -</a> | <a href="#" onClick="swapLayers('lyr2'); return false">- Layer 2 -</a> | <a href="#" onClick="swapLayers('lyr3'); return false">- Layer 3 -</a> </p> <div id="lyr1"> <h2>- Layer 1 -</h2> <p>You can save or view this document's source code using your browser menu commands. Please read dyn-web's <a href="#">Terms of Use</a>.</p> <p>The code is very simple. Position the layers absolute, giving them all the same left, top and width settings. An onload handler can show the first layer when the document loads.</p> <p>A global variable keeps track of the currently visible layer so it can be hidden when a link is clicked to show another.</p> </div> <div id="lyr2"> <h2>- Layer 2 -</h2> <p>This version puts the layers at specified (absolute) positions. It is possible for your layers to appear inline in your page, i.e., relative to other page content, for example in a table cell.</p> <p>See the <a href="#">inline</a> example.</p> </div> <div id="lyr3"> <h2>- Layer 3 -</h2> <p>Code is available to <a href="#">change the style</a> of the link clicked on. This helps the user know which layer they are currently viewing.</p> </div> </body> </html>
Partager