「JavaScript」document.locationのサンプル

2021年8月13日

説明
Document.location は読み取り専用のプロパティで、この文書の URL に関する情報を持った Location オブジェクトを返します。

使用例1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
document.location = 'http://www.arkgame.com' ;
document.location = 'http://www.arkgame.com' ;
document.location = 'http://www.arkgame.com' ;

使用例2

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<input type="button" value="作成" onclick="document.location.href='createuser.do?no=110'">
<input type="button" value="作成" onclick="document.location.href='createuser.do?no=110'">
<input type="button" value="作成" onclick="document.location.href='createuser.do?no=110'">

使用例3

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<script>
function funcA(){
var cft = document.location;
console.log(cft);
}
</script>
<input type="button" value="テスト" onclick="funcA();">
<script> function funcA(){ var cft = document.location; console.log(cft); } </script> <input type="button" value="テスト" onclick="funcA();">
<script>
  function funcA(){
   var cft = document.location;
   console.log(cft);
  }
</script>
<input type="button" value="テスト" onclick="funcA();">

 

JavaScript

Posted by arkgame