質問するログイン新規登録

回答編集履歴

2

質問者名\(ishipp さん\)を追記

2017/03/20 16:38

投稿

think49
think49

スコア18194

answer CHANGED
@@ -36,4 +36,4 @@
36
36
  console.log(new URL('foo.jpg', location.protocol + '//' + location.host + location.pathname).href);
37
37
  ```
38
38
 
39
- Re: さん
39
+ Re: ishipp さん

1

HTMLImageElement#src のサンプルコード追記

2017/03/20 16:38

投稿

think49
think49

スコア18194

answer CHANGED
@@ -20,8 +20,12 @@
20
20
 
21
21
  ```JavaScript
22
22
  var a = document.createElement('a');
23
- a.href = 'foo.jpg';
23
+ a.href = 'foo.jpg'; // HTMLAnchorElement#href
24
24
  console.log(a.href);
25
+
26
+ var img = new Image;
27
+ img.src = 'foo.jpg'; // HTMLImageElement#src
28
+ console.log(img.src);
25
29
  ```
26
30
 
27
31
  `URL` コンストラクタは `window.location` と似た Interface を持ちます。