回答編集履歴

2

見直しキャンペーン中

2023/07/29 13:49

投稿

TN8001
TN8001

スコア9862

test CHANGED
@@ -1,179 +1,90 @@
1
1
  こういうことですか?
2
2
 
3
-
4
-
5
- ```C#
3
+ ```cs
6
-
7
4
  using System;
8
-
9
5
  using System.Diagnostics;
10
-
11
6
  using System.IO;
12
7
 
13
-
14
-
15
8
  namespace Questions376049
16
-
17
9
  {
18
-
19
10
  internal class Program
20
-
21
11
  {
22
-
23
12
  static void Main()
24
-
25
13
  {
26
-
27
14
  var s = @"
28
-
29
15
  <html><body>
30
16
 
31
-
32
-
33
17
  <script>
34
-
35
18
  document.write( ""<div>location.hrefは「 "" + location.href + ""」</div> "");
36
-
37
19
  document.write( ""<div>location.protocolは「 "" + location.protocol + ""」</div> "");
38
-
39
20
  document.write( ""<div>location.hostnameは「 "" + location.hostname + ""」</div> "");
40
-
41
21
  document.write( ""<div>location.hostは「 "" + location.host + ""」</div> "");
42
-
43
22
  document.write( ""<div>location.portは「 "" + location.port + ""」</div> "");
44
-
45
23
  document.write( ""<div>location.pathnameは「 "" + location.pathname + ""」</div> "");
46
-
47
24
  document.write( ""<div>location.searchは「 "" + location.search + ""」</div> "");
48
-
49
25
  document.write( ""<div>location.hashは「 "" + location.hash + ""」</div> "");
50
-
51
26
  </script>
52
27
 
53
-
54
-
55
28
  </body></html>
56
-
57
29
  ".Trim();
58
-
59
30
  File.WriteAllText("test.html", s);
60
31
 
61
-
62
-
63
32
  var p = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.html");
64
-
65
33
  Process.Start($"msedge.exe", $@"""file:///{p}?q=javascript#link""");
66
-
67
34
  }
68
-
69
35
  }
70
-
71
36
  }
72
-
73
37
  ```
74
-
75
38
  ![edge](94da14aa724e510d923df0388aef796e.png)
76
-
77
-
78
39
 
79
40
  [c# - Process.Start(link) omits part of the link - Stack Overflow](https://stackoverflow.com/questions/13550837/process-startlink-omits-part-of-the-link)
80
41
 
81
-
82
-
83
42
  [.net - How to launch MS Edge from c# winforms? - Stack Overflow](https://stackoverflow.com/questions/39626509/how-to-launch-ms-edge-from-c-sharp-winforms)
84
-
85
-
86
43
 
87
44
  [location.search-JavaScriptリファレンス](http://www.htmq.com/js/location_search.shtml?aaa)
88
45
 
89
-
90
-
91
46
  ---
92
47
 
93
-
94
-
95
48
  追記 ページ内リンク
96
-
97
- ```C#
49
+ ```cs
98
-
99
50
  using System.Diagnostics;
100
-
101
51
  using System.IO;
102
52
 
103
-
104
-
105
53
  namespace Questions376049
106
-
107
54
  {
108
-
109
55
  internal class Program
110
-
111
56
  {
112
-
113
57
  static void Main()
114
-
115
58
  {
116
-
117
59
  var s = @"
118
-
119
60
  <!DOCTYPE html>
120
-
121
61
  <html lang=""ja"">
122
-
123
62
  <head>
124
-
125
63
  <meta charset=""utf-8"">
126
-
127
64
  <title>ページ内リンク</title>
128
-
129
65
  </head>
130
66
 
131
-
132
-
133
67
  <body>
134
-
135
68
  <h1 id=""page1"">ページ1</h1>
136
-
137
69
  <p style=""margin-bottom: 5000px;"">
138
-
139
70
  <a href=""file:///c:/temp/doc.html#page2"">ページ2へ</a>
140
-
141
71
  </p>
142
72
 
143
-
144
-
145
73
  <h1 id=""page2"">ページ2</h1>
146
-
147
74
  <p style=""margin-bottom: 5000px;"">
148
-
149
75
  <a href=""file:///c:/temp/doc.html#page3"">ページ3へ</a>
150
-
151
76
  </p>
152
77
 
153
-
154
-
155
78
  <h1 id=""page3"">ページ3</h1>
156
-
157
79
  <p style=""margin-bottom: 5000px;"">
158
-
159
80
  <a href=""file:///c:/temp/doc.html#page1"">ページ1へ</a>
160
-
161
81
  </p>
162
82
 
163
-
164
-
165
83
  </body>
166
-
167
84
  </html>".Trim();
168
-
169
85
  File.WriteAllText(@"c:\temp\doc.html", s);
170
-
171
86
  Process.Start($"msedge.exe", $@"""file:///c:/temp/doc.html#page3""");
172
-
173
87
  }
174
-
175
88
  }
176
-
177
89
  }
178
-
179
90
  ```

1

ページ内リンク

2021/12/31 07:53

投稿

TN8001
TN8001

スコア9862

test CHANGED
@@ -85,3 +85,95 @@
85
85
 
86
86
 
87
87
  [location.search-JavaScriptリファレンス](http://www.htmq.com/js/location_search.shtml?aaa)
88
+
89
+
90
+
91
+ ---
92
+
93
+
94
+
95
+ 追記 ページ内リンク
96
+
97
+ ```C#
98
+
99
+ using System.Diagnostics;
100
+
101
+ using System.IO;
102
+
103
+
104
+
105
+ namespace Questions376049
106
+
107
+ {
108
+
109
+ internal class Program
110
+
111
+ {
112
+
113
+ static void Main()
114
+
115
+ {
116
+
117
+ var s = @"
118
+
119
+ <!DOCTYPE html>
120
+
121
+ <html lang=""ja"">
122
+
123
+ <head>
124
+
125
+ <meta charset=""utf-8"">
126
+
127
+ <title>ページ内リンク</title>
128
+
129
+ </head>
130
+
131
+
132
+
133
+ <body>
134
+
135
+ <h1 id=""page1"">ページ1</h1>
136
+
137
+ <p style=""margin-bottom: 5000px;"">
138
+
139
+ <a href=""file:///c:/temp/doc.html#page2"">ページ2へ</a>
140
+
141
+ </p>
142
+
143
+
144
+
145
+ <h1 id=""page2"">ページ2</h1>
146
+
147
+ <p style=""margin-bottom: 5000px;"">
148
+
149
+ <a href=""file:///c:/temp/doc.html#page3"">ページ3へ</a>
150
+
151
+ </p>
152
+
153
+
154
+
155
+ <h1 id=""page3"">ページ3</h1>
156
+
157
+ <p style=""margin-bottom: 5000px;"">
158
+
159
+ <a href=""file:///c:/temp/doc.html#page1"">ページ1へ</a>
160
+
161
+ </p>
162
+
163
+
164
+
165
+ </body>
166
+
167
+ </html>".Trim();
168
+
169
+ File.WriteAllText(@"c:\temp\doc.html", s);
170
+
171
+ Process.Start($"msedge.exe", $@"""file:///c:/temp/doc.html#page3""");
172
+
173
+ }
174
+
175
+ }
176
+
177
+ }
178
+
179
+ ```