回答編集履歴
2
ちょうせい
test
CHANGED
@@ -7,8 +7,6 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
```javascript
|
10
|
-
|
11
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
12
10
|
|
13
11
|
<script>
|
14
12
|
|
1
sample
test
CHANGED
@@ -1 +1,35 @@
|
|
1
1
|
location.hashを評価して、?id=id名と同等のロジックにはめてやればいいでしょう
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
# sample
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
```javascript
|
10
|
+
|
11
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
|
15
|
+
$(window).on('popstate pageshow',function(){
|
16
|
+
|
17
|
+
var selector="";
|
18
|
+
|
19
|
+
if(r=location.search.match(/[?&]id=(.+?)(?=&|$)/)) selector="#"+r[1];
|
20
|
+
|
21
|
+
if(h=location.hash) selector=h;
|
22
|
+
|
23
|
+
console.log(selector);
|
24
|
+
|
25
|
+
});
|
26
|
+
|
27
|
+
</script>
|
28
|
+
|
29
|
+
<a href="?id=hoge">hoge</a><br>
|
30
|
+
|
31
|
+
<a href="#fuga">fuga</a><br>
|
32
|
+
|
33
|
+
<a href="?id=piyopiyo#piyo">piyo</a><br>
|
34
|
+
|
35
|
+
```
|