IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Double ancre grâce à Javascript ?


Sujet :

JavaScript

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 1
    Points
    1
    Par défaut Double ancre grâce à Javascript ?
    Bonsoir,

    Je n'ai aucune connaissance en javascript, et je me tourne donc vers vous.

    J'ai téléchargé ce site : https://html5up.net/dimension
    Il permet d'ouvrir plusieurs pages du site sur le même fichier html.

    Le menu permet d'ouvrir le contenu d'un <article> </article> grâce à une ancre et a l'action script javascript.

    Cependant, j'aimerais faire des sous-menu, qui mèneront donc au contenu de <article> et à une autre ancre qui sera dans la page ouverte par le script.

    Serait-ce possible ?
    Merci d'avance !

    PS: pour ceux qui n'ont pas envie de télécharger les fichier, voici les codes :

    Code html : 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
    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
    <!DOCTYPE HTML>
    <!--
    	Dimension by HTML5 UP
    	html5up.net | @ajlkn
    	Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
    -->
    <html>
    	<head>
    		<title>Dimension by HTML5 UP</title>
    		<meta charset="utf-8" />
    		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    		<link rel="stylesheet" href="assets/css/main.css" />
    		<!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie9.css" /><![endif]-->
    		<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
    	</head>
    	<body>
     
    		<!-- Wrapper -->
    			<div id="wrapper">
     
    				<!-- Header -->
    					<header id="header">
    						<div class="logo">
    							<span class="icon fa-diamond"></span>
    						</div>
    						<div class="content">
    							<div class="inner">
    								<h1>Dimension</h1>
    								<p><!--[-->A fully responsive site template designed by <a href="https://html5up.net">HTML5 UP</a> and released<!--]--><br />
    								<!--[-->for free under the <a href="https://html5up.net/license">Creative Commons</a> license.<!--]--></p>
    							</div>
    						</div>
    						<nav>
    							<ul>
    								<li><a href="#intro">Intro</a></li>
    								<li><a href="#work">Work</a></li>
    								<li><a href="#about">About</a></li>
    								<li><a href="#contact">Contact</a></li>
    								<!--<li><a href="#elements">Elements</a></li>-->
    							</ul>
    						</nav>
    					</header>
     
    				<!-- Main -->
    					<div id="main">
     
    						<!-- Intro -->
    							<article id="intro">
    								<h2 class="major">Intro</h2>
    								<span class="image main"><img src="images/pic01.jpg" alt="" /></span>
    								<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. By the way, check out my <a href="#work">awesome work</a>.</p>
    								<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dapibus rutrum facilisis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam tristique libero eu nibh porttitor fermentum. Nullam venenatis erat id vehicula viverra. Nunc ultrices eros ut ultricies condimentum. Mauris risus lacus, blandit sit amet venenatis non, bibendum vitae dolor. Nunc lorem mauris, fringilla in aliquam at, euismod in lectus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In non lorem sit amet elit placerat maximus. Pellentesque aliquam maximus risus, vel sed vehicula.</p>
    							</article>
     
    						<!-- Work -->
    							<article id="work">
    								<h2 class="major">Work</h2>
    								<span class="image main"><img src="images/pic02.jpg" alt="" /></span>
    								<p>Adipiscing magna sed dolor elit. Praesent eleifend dignissim arcu, at eleifend sapien imperdiet ac. Aliquam erat volutpat. Praesent urna nisi, fringila lorem et vehicula lacinia quam. Integer sollicitudin mauris nec lorem luctus ultrices.</p>
    								<p>Nullam et orci eu lorem consequat tincidunt vivamus et sagittis libero. Mauris aliquet magna magna sed nunc rhoncus pharetra. Pellentesque condimentum sem. In efficitur ligula tate urna. Maecenas laoreet massa vel lacinia pellentesque lorem ipsum dolor. Nullam et orci eu lorem consequat tincidunt. Vivamus et sagittis libero. Mauris aliquet magna magna sed nunc rhoncus amet feugiat tempus.</p>
    							</article>
     
    						<!-- About -->
    							<article id="about">
    								<h2 class="major">About</h2>
    								<span class="image main"><img src="images/pic03.jpg" alt="" /></span>
    								<p>Lorem ipsum dolor sit amet, consectetur et adipiscing elit. Praesent eleifend dignissim arcu, at eleifend sapien imperdiet ac. Aliquam erat volutpat. Praesent urna nisi, fringila lorem et vehicula lacinia quam. Integer sollicitudin mauris nec lorem luctus ultrices. Aliquam libero et malesuada fames ac ante ipsum primis in faucibus. Cras viverra ligula sit amet ex mollis mattis lorem ipsum dolor sit amet.</p>
    							</article>
     
    						<!-- Contact -->
    							<article id="contact">
    								<h2 class="major">Contact</h2>
    								<form method="post" action="#">
    									<div class="field half first">
    										<label for="name">Name</label>
    										<input type="text" name="name" id="name" />
    									</div>
    									<div class="field half">
    										<label for="email">Email</label>
    										<input type="text" name="email" id="email" />
    									</div>
    									<div class="field">
    										<label for="message">Message</label>
    										<textarea name="message" id="message" rows="4"></textarea>
    									</div>
    									<ul class="actions">
    										<li><input type="submit" value="Send Message" class="special" /></li>
    										<li><input type="reset" value="Reset" /></li>
    									</ul>
    								</form>
    								<ul class="icons">
    									<li><a href="#" class="icon fa-twitter"><span class="label">Twitter</span></a></li>
    									<li><a href="#" class="icon fa-facebook"><span class="label">Facebook</span></a></li>
    									<li><a href="#" class="icon fa-instagram"><span class="label">Instagram</span></a></li>
    									<li><a href="#" class="icon fa-github"><span class="label">GitHub</span></a></li>
    								</ul>
    							</article>
     
    						<!-- Elements -->
    							<article id="elements">
    								<h2 class="major">Elements</h2>
     
    								<section>
    									<h3 class="major">Text</h3>
    									<p>This is <b>bold</b> and this is <strong>strong</strong>. This is <i>italic</i> and this is <em>emphasized</em>.
    									This is <sup>superscript</sup> text and this is <sub>subscript</sub> text.
    									This is <u>underlined</u> and this is code: <code>for (;;) { ... }</code>. Finally, <a href="#">this is a link</a>.</p>
    									<hr />
    									<h2>Heading Level 2</h2>
    									<h3>Heading Level 3</h3>
    									<h4>Heading Level 4</h4>
    									<h5>Heading Level 5</h5>
    									<h6>Heading Level 6</h6>
    									<hr />
    									<h4>Blockquote</h4>
    									<blockquote>Fringilla nisl. Donec accumsan interdum nisi, quis tincidunt felis sagittis eget tempus euismod. Vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan faucibus. Vestibulum ante ipsum primis in faucibus lorem ipsum dolor sit amet nullam adipiscing eu felis.</blockquote>
    									<h4>Preformatted</h4>
    									<pre><code>i = 0;
     
    while (!deck.isInOrder()) {
        print 'Iteration ' + i;
        deck.shuffle();
        i++;
    }
     
    print 'It took ' + i + ' iterations to sort the deck.';</code></pre>
    								</section>
     
    								<section>
    									<h3 class="major">Lists</h3>
     
    									<h4>Unordered</h4>
    									<ul>
    										<li>Dolor pulvinar etiam.</li>
    										<li>Sagittis adipiscing.</li>
    										<li>Felis enim feugiat.</li>
    									</ul>
     
    									<h4>Alternate</h4>
    									<ul class="alt">
    										<li>Dolor pulvinar etiam.</li>
    										<li>Sagittis adipiscing.</li>
    										<li>Felis enim feugiat.</li>
    									</ul>
     
    									<h4>Ordered</h4>
    									<ol>
    										<li>Dolor pulvinar etiam.</li>
    										<li>Etiam vel felis viverra.</li>
    										<li>Felis enim feugiat.</li>
    										<li>Dolor pulvinar etiam.</li>
    										<li>Etiam vel felis lorem.</li>
    										<li>Felis enim et feugiat.</li>
    									</ol>
    									<h4>Icons</h4>
    									<ul class="icons">
    										<li><a href="#" class="icon fa-twitter"><span class="label">Twitter</span></a></li>
    										<li><a href="#" class="icon fa-facebook"><span class="label">Facebook</span></a></li>
    										<li><a href="#" class="icon fa-instagram"><span class="label">Instagram</span></a></li>
    										<li><a href="#" class="icon fa-github"><span class="label">Github</span></a></li>
    									</ul>
     
    									<h4>Actions</h4>
    									<ul class="actions">
    										<li><a href="#" class="button special">Default</a></li>
    										<li><a href="#" class="button">Default</a></li>
    									</ul>
    									<ul class="actions vertical">
    										<li><a href="#" class="button special">Default</a></li>
    										<li><a href="#" class="button">Default</a></li>
    									</ul>
    								</section>
     
    								<section>
    									<h3 class="major">Table</h3>
    									<h4>Default</h4>
    									<div class="table-wrapper">
    										<table>
    											<thead>
    												<tr>
    													<th>Name</th>
    													<th>Description</th>
    													<th>Price</th>
    												</tr>
    											</thead>
    											<tbody>
    												<tr>
    													<td>Item One</td>
    													<td>Ante turpis integer aliquet porttitor.</td>
    													<td>29.99</td>
    												</tr>
    												<tr>
    													<td>Item Two</td>
    													<td>Vis ac commodo adipiscing arcu aliquet.</td>
    													<td>19.99</td>
    												</tr>
    												<tr>
    													<td>Item Three</td>
    													<td> Morbi faucibus arcu accumsan lorem.</td>
    													<td>29.99</td>
    												</tr>
    												<tr>
    													<td>Item Four</td>
    													<td>Vitae integer tempus condimentum.</td>
    													<td>19.99</td>
    												</tr>
    												<tr>
    													<td>Item Five</td>
    													<td>Ante turpis integer aliquet porttitor.</td>
    													<td>29.99</td>
    												</tr>
    											</tbody>
    											<tfoot>
    												<tr>
    													<td colspan="2"></td>
    													<td>100.00</td>
    												</tr>
    											</tfoot>
    										</table>
    									</div>
     
    									<h4>Alternate</h4>
    									<div class="table-wrapper">
    										<table class="alt">
    											<thead>
    												<tr>
    													<th>Name</th>
    													<th>Description</th>
    													<th>Price</th>
    												</tr>
    											</thead>
    											<tbody>
    												<tr>
    													<td>Item One</td>
    													<td>Ante turpis integer aliquet porttitor.</td>
    													<td>29.99</td>
    												</tr>
    												<tr>
    													<td>Item Two</td>
    													<td>Vis ac commodo adipiscing arcu aliquet.</td>
    													<td>19.99</td>
    												</tr>
    												<tr>
    													<td>Item Three</td>
    													<td> Morbi faucibus arcu accumsan lorem.</td>
    													<td>29.99</td>
    												</tr>
    												<tr>
    													<td>Item Four</td>
    													<td>Vitae integer tempus condimentum.</td>
    													<td>19.99</td>
    												</tr>
    												<tr>
    													<td>Item Five</td>
    													<td>Ante turpis integer aliquet porttitor.</td>
    													<td>29.99</td>
    												</tr>
    											</tbody>
    											<tfoot>
    												<tr>
    													<td colspan="2"></td>
    													<td>100.00</td>
    												</tr>
    											</tfoot>
    										</table>
    									</div>
    								</section>
     
    								<section>
    									<h3 class="major">Buttons</h3>
    									<ul class="actions">
    										<li><a href="#" class="button special">Special</a></li>
    										<li><a href="#" class="button">Default</a></li>
    									</ul>
    									<ul class="actions">
    										<li><a href="#" class="button">Default</a></li>
    										<li><a href="#" class="button small">Small</a></li>
    									</ul>
    									<ul class="actions">
    										<li><a href="#" class="button special icon fa-download">Icon</a></li>
    										<li><a href="#" class="button icon fa-download">Icon</a></li>
    									</ul>
    									<ul class="actions">
    										<li><span class="button special disabled">Disabled</span></li>
    										<li><span class="button disabled">Disabled</span></li>
    									</ul>
    								</section>
     
    								<section>
    									<h3 class="major">Form</h3>
    									<form method="post" action="#">
    										<div class="field half first">
    											<label for="demo-name">Name</label>
    											<input type="text" name="demo-name" id="demo-name" value="" placeholder="Jane Doe" />
    										</div>
    										<div class="field half">
    											<label for="demo-email">Email</label>
    											<input type="email" name="demo-email" id="demo-email" value="" placeholder="jane@untitled.tld" />
    										</div>
    										<div class="field">
    											<label for="demo-category">Category</label>
    											<div class="select-wrapper">
    												<select name="demo-category" id="demo-category">
    													<option value="">-</option>
    													<option value="1">Manufacturing</option>
    													<option value="1">Shipping</option>
    													<option value="1">Administration</option>
    													<option value="1">Human Resources</option>
    												</select>
    											</div>
    										</div>
    										<div class="field half first">
    											<input type="radio" id="demo-priority-low" name="demo-priority" checked>
    											<label for="demo-priority-low">Low</label>
    										</div>
    										<div class="field half">
    											<input type="radio" id="demo-priority-high" name="demo-priority">
    											<label for="demo-priority-high">High</label>
    										</div>
    										<div class="field half first">
    											<input type="checkbox" id="demo-copy" name="demo-copy">
    											<label for="demo-copy">Email me a copy</label>
    										</div>
    										<div class="field half">
    											<input type="checkbox" id="demo-human" name="demo-human" checked>
    											<label for="demo-human">Not a robot</label>
    										</div>
    										<div class="field">
    											<label for="demo-message">Message</label>
    											<textarea name="demo-message" id="demo-message" placeholder="Enter your message" rows="6"></textarea>
    										</div>
    										<ul class="actions">
    											<li><input type="submit" value="Send Message" class="special" /></li>
    											<li><input type="reset" value="Reset" /></li>
    										</ul>
    									</form>
    								</section>
     
    							</article>
     
    					</div>
     
    				<!-- Footer -->
    					<footer id="footer">
    						<p class="copyright">&copy; Untitled. Design: <a href="https://html5up.net">HTML5 UP</a>.</p>
    					</footer>
     
    			</div>
     
    		<!-- BG -->
    			<div id="bg"></div>
     
    		<!-- Scripts -->
    			<script src="assets/js/jquery.min.js"></script>
    			<script src="assets/js/skel.min.js"></script>
    			<script src="assets/js/util.js"></script>
    			<script src="assets/js/main.js"></script>
     
    	</body>
    </html>

    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
    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
    /*
    	Dimension by HTML5 UP
    	html5up.net | @ajlkn
    	Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
    */
     
    (function($) {
     
    	skel.breakpoints({
    		xlarge:		'(max-width: 1680px)',
    		large:		'(max-width: 1280px)',
    		medium:		'(max-width: 980px)',
    		small:		'(max-width: 736px)',
    		xsmall:		'(max-width: 480px)',
    		xxsmall:	'(max-width: 360px)'
    	});
     
    	$(function() {
     
    		var	$window = $(window),
    			$body = $('body'),
    			$wrapper = $('#wrapper'),
    			$header = $('#header'),
    			$footer = $('#footer'),
    			$main = $('#main'),
    			$main_articles = $main.children('article');
     
    		// Disable animations/transitions until the page has loaded.
    			$body.addClass('is-loading');
     
    			$window.on('load', function() {
    				window.setTimeout(function() {
    					$body.removeClass('is-loading');
    				}, 100);
    			});
     
    		// Fix: Placeholder polyfill.
    			$('form').placeholder();
     
    		// Fix: Flexbox min-height bug on IE.
    			if (skel.vars.IEVersion < 12) {
     
    				var flexboxFixTimeoutId;
     
    				$window.on('resize.flexbox-fix', function() {
     
    					clearTimeout(flexboxFixTimeoutId);
     
    					flexboxFixTimeoutId = setTimeout(function() {
     
    						if ($wrapper.prop('scrollHeight') > $window.height())
    							$wrapper.css('height', 'auto');
    						else
    							$wrapper.css('height', '100vh');
     
    					}, 250);
     
    				}).triggerHandler('resize.flexbox-fix');
     
    			}
     
    		// Nav.
    			var $nav = $header.children('nav'),
    				$nav_li = $nav.find('li');
     
    			// Add "middle" alignment classes if we're dealing with an even number of items.
    				if ($nav_li.length % 2 == 0) {
     
    					$nav.addClass('use-middle');
    					$nav_li.eq( ($nav_li.length / 2) ).addClass('is-middle');
     
    				}
     
    		// Main.
    			var	delay = 325,
    				locked = false;
     
    			// Methods.
    				$main._show = function(id, initial) {
     
    					var $article = $main_articles.filter('#' + id);
     
    					// No such article? Bail.
    						if ($article.length == 0)
    							return;
     
    					// Handle lock.
     
    						// Already locked? Speed through "show" steps w/o delays.
    							if (locked || (typeof initial != 'undefined' && initial === true)) {
     
    								// Mark as switching.
    									$body.addClass('is-switching');
     
    								// Mark as visible.
    									$body.addClass('is-article-visible');
     
    								// Deactivate all articles (just in case one's already active).
    									$main_articles.removeClass('active');
     
    								// Hide header, footer.
    									$header.hide();
    									$footer.hide();
     
    								// Show main, article.
    									$main.show();
    									$article.show();
     
    								// Activate article.
    									$article.addClass('active');
     
    								// Unlock.
    									locked = false;
     
    								// Unmark as switching.
    									setTimeout(function() {
    										$body.removeClass('is-switching');
    									}, (initial ? 1000 : 0));
     
    								return;
     
    							}
     
    						// Lock.
    							locked = true;
     
    					// Article already visible? Just swap articles.
    						if ($body.hasClass('is-article-visible')) {
     
    							// Deactivate current article.
    								var $currentArticle = $main_articles.filter('.active');
     
    								$currentArticle.removeClass('active');
     
    							// Show article.
    								setTimeout(function() {
     
    									// Hide current article.
    										$currentArticle.hide();
     
    									// Show article.
    										$article.show();
     
    									// Activate article.
    										setTimeout(function() {
     
    											$article.addClass('active');
     
    											// Window stuff.
    												$window
    													.scrollTop(0)
    													.triggerHandler('resize.flexbox-fix');
     
    											// Unlock.
    												setTimeout(function() {
    													locked = false;
    												}, delay);
     
    										}, 25);
     
    								}, delay);
     
    						}
     
    					// Otherwise, handle as normal.
    						else {
     
    							// Mark as visible.
    								$body
    									.addClass('is-article-visible');
     
    							// Show article.
    								setTimeout(function() {
     
    									// Hide header, footer.
    										$header.hide();
    										$footer.hide();
     
    									// Show main, article.
    										$main.show();
    										$article.show();
     
    									// Activate article.
    										setTimeout(function() {
     
    											$article.addClass('active');
     
    											// Window stuff.
    												$window
    													.scrollTop(0)
    													.triggerHandler('resize.flexbox-fix');
     
    											// Unlock.
    												setTimeout(function() {
    													locked = false;
    												}, delay);
     
    										}, 25);
     
    								}, delay);
     
    						}
     
    				};
     
    				$main._hide = function(addState) {
     
    					var $article = $main_articles.filter('.active');
     
    					// Article not visible? Bail.
    						if (!$body.hasClass('is-article-visible'))
    							return;
     
    					// Add state?
    						if (typeof addState != 'undefined'
    						&&	addState === true)
    							history.pushState(null, null, '#');
     
    					// Handle lock.
     
    						// Already locked? Speed through "hide" steps w/o delays.
    							if (locked) {
     
    								// Mark as switching.
    									$body.addClass('is-switching');
     
    								// Deactivate article.
    									$article.removeClass('active');
     
    								// Hide article, main.
    									$article.hide();
    									$main.hide();
     
    								// Show footer, header.
    									$footer.show();
    									$header.show();
     
    								// Unmark as visible.
    									$body.removeClass('is-article-visible');
     
    								// Unlock.
    									locked = false;
     
    								// Unmark as switching.
    									$body.removeClass('is-switching');
     
    								// Window stuff.
    									$window
    										.scrollTop(0)
    										.triggerHandler('resize.flexbox-fix');
     
    								return;
     
    							}
     
    						// Lock.
    							locked = true;
     
    					// Deactivate article.
    						$article.removeClass('active');
     
    					// Hide article.
    						setTimeout(function() {
     
    							// Hide article, main.
    								$article.hide();
    								$main.hide();
     
    							// Show footer, header.
    								$footer.show();
    								$header.show();
     
    							// Unmark as visible.
    								setTimeout(function() {
     
    									$body.removeClass('is-article-visible');
     
    									// Window stuff.
    										$window
    											.scrollTop(0)
    											.triggerHandler('resize.flexbox-fix');
     
    									// Unlock.
    										setTimeout(function() {
    											locked = false;
    										}, delay);
     
    								}, 25);
     
    						}, delay);
     
     
    				};
     
    			// Articles.
    				$main_articles.each(function() {
     
    					var $this = $(this);
     
    					// Close.
    						$('<div class="close">Close</div>')
    							.appendTo($this)
    							.on('click', function() {
    								location.hash = '';
    							});
     
    					// Prevent clicks from inside article from bubbling.
    						$this.on('click', function(event) {
    							event.stopPropagation();
    						});
     
    				});
     
    			// Events.
    				$body.on('click', function(event) {
     
    					// Article visible? Hide.
    						if ($body.hasClass('is-article-visible'))
    							$main._hide(true);
     
    				});
     
    				$window.on('keyup', function(event) {
     
    					switch (event.keyCode) {
     
    						case 27:
     
    							// Article visible? Hide.
    								if ($body.hasClass('is-article-visible'))
    									$main._hide(true);
     
    							break;
     
    						default:
    							break;
     
    					}
     
    				});
     
    				$window.on('hashchange', function(event) {
     
    					// Empty hash?
    						if (location.hash == ''
    						||	location.hash == '#') {
     
    							// Prevent default.
    								event.preventDefault();
    								event.stopPropagation();
     
    							// Hide.
    								$main._hide();
     
    						}
     
    					// Otherwise, check for a matching article.
    						else if ($main_articles.filter(location.hash).length > 0) {
     
    							// Prevent default.
    								event.preventDefault();
    								event.stopPropagation();
     
    							// Show article.
    								$main._show(location.hash.substr(1));
     
    						}
     
    				});
     
    			// Scroll restoration.
    			// This prevents the page from scrolling back to the top on a hashchange.
    				if ('scrollRestoration' in history)
    					history.scrollRestoration = 'manual';
    				else {
     
    					var	oldScrollPos = 0,
    						scrollPos = 0,
    						$htmlbody = $('html,body');
     
    					$window
    						.on('scroll', function() {
     
    							oldScrollPos = scrollPos;
    							scrollPos = $htmlbody.scrollTop();
     
    						})
    						.on('hashchange', function() {
    							$window.scrollTop(oldScrollPos);
    						});
     
    				}
     
    			// Initialize.
     
    				// Hide main, articles.
    					$main.hide();
    					$main_articles.hide();
     
    				// Initial article.
    					if (location.hash != ''
    					&&	location.hash != '#')
    						$window.on('load', function() {
    							$main._show(location.hash.substr(1), true);
    						});
     
    	});
     
    })(jQuery);

  2. #2
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    Je me permets un up x')

    Je comprends que ma question soit extrêmement vague , et il doit-être long (peut-être) de trouver une solution, mais elle est un peu urgente.

    Si quelqu'un avait le temps et le courage de m'aider, ça serait super sympa

    Si vous avez besoin d'autres infos, j'essayerais d'y répondre.

    PS :

    Voici la partie de la navigation que j'ai modifié avec les sous-menus :


    Code html : 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
    						<nav>
    							<ul id="menu-demo2" style="display: -moz-flex; display: -webkit-flex; display: -ms-flex;display: flex;" >
     
    								<li><a href="#page1"><div style="line-height:20px">Menu1</div></a>
    								<ul style="display:block; font-size:10px;">
    			<li><a href="#Ancre1Page1">Sous-menu1</a></li>
    			<li><a href="#Ancre2Page1">Sous-menu2</a></li>
    			<li><a href="#Ancre3Page1">Sous-menu3</a></li>
    		</ul></li>
    								<li><a href="#page2"><div style="line-height:20px">Menu2</div></a>
    <ul style="display:block; font-size:10px;">
    			<li><a href="#Ancre1Page2">Sous-menu1</a></li>
    			<li><a href="#Ancre2Page2">Sous-menu2</a></li>
    		</ul></li>
    								<li><a href="#page2"><div style="line-height:20px">Menu3</div></a>
    								<ul style="display:block; font-size:10px;">
    			<li><a href="#Ancre1Page3">Sous-menu1</a></li>
    			<li><a href="#Ancre2Page3">Sous-menu2</a></li>
    			<li><a href="#Ancre3Page3">Sous-menu3</a></li>
    		</ul></li>

  3. #3
    Membre émérite
    Avatar de badaze
    Homme Profil pro
    Chef de projets info
    Inscrit en
    Septembre 2002
    Messages
    1 412
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projets info
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2002
    Messages : 1 412
    Points : 2 522
    Points
    2 522
    Par défaut
    Je ne vois pas le lien entre ton code du second message et celui du premier (au fait, il manque la balise </nav>).

    Tu dis Cependant, j'aimerais faire des sous-menu, qui mèneront donc au contenu de <article> et à une autre ancre qui sera dans la page ouverte par le script. La seconde partie n'est pas claire du tout.

    Dans l'exemple que tu donnes (1er message), l'accès aux articles se fait à partir du code suivant :
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <ul>
            <li><a href="#intro">Intro</a></li>
            <li><a href="#work">Work</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
            <!--<li><a href="#elements">Elements</a></li>-->
    </ul>
    Cela ne sert à rien d'optimiser quelque chose qui ne fonctionne pas.

    Mon site : www.emmella.fr

    Je recherche le manuel de l'Olivetti Logos 80B.

  4. #4
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    En fait, c'est juste la base d'un site que j'ai modifié.

    Du coup, j'ai changé le nom des parties, et ajouté des sous-parties.

    Je sais que ce n'est pas clair , mais j'ai essayé de m'expliquer au mieux.

    Pour faire plus simple :

    J'aimerais que quand je clic sur le sous-menu1 du menu1 (cf code html), le javascript ouvre la page du menu1, et fasse descendre à la partie 1.

    Bon, si ce n'est pas du tout clair encore, voici mon site (je ne sais pas si la "pub" est interdite, mais rien que le nom du site fait savoir que je n'ai aucune intention à ce que mon site soit connu )

    http://tpe-tdah.fr/

    Quand je clic sur : "des effets importants : le méthylphénidate", je voudrais que "comprendre pour compenser" s'ouvre, et qu'on descende vers la partie b (regarder le site pour comprendre).

    Merci de votre réponse !

  5. #5
    Membre émérite
    Avatar de badaze
    Homme Profil pro
    Chef de projets info
    Inscrit en
    Septembre 2002
    Messages
    1 412
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projets info
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2002
    Messages : 1 412
    Points : 2 522
    Points
    2 522
    Par défaut
    Essaie comme ça. Mais je ne suis pas sûr de moi.

    Nom : 20170225-001.jpg
Affichages : 226
Taille : 139,4 Ko
    Cela ne sert à rien d'optimiser quelque chose qui ne fonctionne pas.

    Mon site : www.emmella.fr

    Je recherche le manuel de l'Olivetti Logos 80B.

  6. #6
    Nouveau Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2013
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2013
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    Non ça ne marche pas :/

Discussions similaires

  1. Lire un json grâce à javascript
    Par jytest dans le forum Général JavaScript
    Réponses: 10
    Dernier message: 29/05/2013, 10h18
  2. Double pagination en javascript
    Par topoto dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 15/10/2012, 21h22
  3. Récupérer informations de champs file grâce à Javascript
    Par rafmos dans le forum Général JavaScript
    Réponses: 19
    Dernier message: 20/08/2010, 16h57
  4. poser une ancre en javascript
    Par skyangel20 dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 31/10/2007, 14h10
  5. [XSL] Opération sur des valeurs XML grâce à Javascript
    Par kimar dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 26/06/2007, 12h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo