-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6-exemplo-abas-link.php
62 lines (55 loc) · 1.28 KB
/
6-exemplo-abas-link.php
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
<!DOCTYPE html>
<html>
<head>
<title>Exemplos Javascript não obstrutivo</title>
<!-- ADICIONA CLASSE NO HTML QUANDO HA SUPORTE -->
<script>document.getElementsByTagName('html')[0].className += ' js'</script>
<style>
ul {
overflow:hidden;
list-style:none;
}
ul li {
float:left;
padding-right:30px;
}
.aba {
display:block;
border-top:solid 1px #CCC;
padding:30px;
}
</style>
</head>
<body>
<h1>Exemplo javascript não obstrutivo em abas / páginas com ajax</h1>
<ul>
<li><a href="aba1.html">Aba 1</a></li>
<li><a href="aba2.html">Aba 2</a></li>
<li><a href="aba3.html">Aba 3</a></li>
<li><a href="aba4.html">Aba 4</a></li>
</ul>
<div class="aba">
<?php
include("aba1.html");
?>
</div>
<!-- TENTA CARREGAR JQUERY EXTERNO, EM CASO DE TIMEOUT CARREGA LOCAL -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="scripts/jquery-1.7.1.min.js"><\/script>')</script>
<script>
var conteudoAbas = $(".aba")
, abas = $("ul a")
, pagina
abas.click(function(e) {
e.preventDefault();
pagina = $(this).attr('href')
$.ajax({
url: pagina,
success: function(data) {
conteudoAbas.html(data)
}
});
});
</script>
</body>
</html>