<script> document.write( '<base href = "' + document.location + '" />'); </ script>

user3824956

次のスクリプトの目的は何ですか?

<head>
<script>document.write('<base href="' + document.location + '" />');</script>
...
</head>

デフォルトパスの最初の部分を設定するためにbasehrefが使用されていることをある程度理解しました。では、これはURLをどこに設定しますか?後で私は使用しています

<body ng-app="plunker" ng-controller="NavCtrl">
    <p>Click one of the following choices.</p>
    <ul>
        <li ng-class="{active: isActive('/tab1')}"><a href="#/tab1">tab 1</a></li>
        <li ng-class="{active: isActive('/tab2')}"><a href="#/tab2">tab 2</a></li>
    </ul>
    <pre>{{ path }}</pre>
</body>

次のコントローラーを使用します。

var app = angular.module('plunker', []);

app.controller('NavCtrl', function($scope, $location) {
    $scope.isActive = function(route) {
        $scope.path = $location.path();
        return $location.path() === route;
    };
});
ルーク・ピーターソン

この<base>要素は、ドキュメントに含まれるすべての相対URLに使用するベースURLを指定します。

Mozillaの開発者向けネットワークの定義:

Document.location読み取り専用プロパティはLocationオブジェクトを返します。このオブジェクトには、ドキュメントのURLに関する情報が含まれ、そのURLを変更して別のURLをロードするためのメソッドが提供されます。

あなたの場合、それbase hrefは現在のURLに設定します。また、document.locationと同等document.location.hrefです。

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

<script> document.write( '<base href =“' + document.location + '” />'); </ script>

分類Dev

<script> document.cookie = "humans_21909 = 1"; document.location.reload(true)</ script>

分類Dev

document.location.hrefとdocument.locationの違いは何ですか?

分類Dev

Load external script which has document.write using ReactJS

分類Dev

document.locationのObject.observe

分類Dev

IE11は、document.location.hrefまたは$(location).attr( "href")を使用して現在のURLを取得できません

分類Dev

javascript document.write( "<base href =" ">"); 動作しない

分類Dev

document.location.href =を実行した後、JQueryを使用して要素にクラスを追加します

分類Dev

What is the '?' in a href when calling a php script?

分類Dev

$ _SESSION ["name"] = "<script> document.write(name)</ script>";を使用せずにjs変数をphpに保存する方法

分類Dev

document.write()で書き込むときに<script>タグを分割する理由

分類Dev

document.createElement( "script")を同期的に

分類Dev

Why is $(document).ready needed after the <script> tag?

分類Dev

Invisible script tag in HTML document with websockets code in it

分類Dev

Here-document not working properly on shell script

分類Dev

Write script to open browser at specific URL on login?

分類Dev

LaunchAgent script can't write to external drive

分類Dev

method to write in log files in a shell script

分類Dev

check cpanel authorisation with perl script and write file

分類Dev

Making PHP Script Automatically write to text file

分類Dev

Crontabbed shell script not able to create/write to a file

分類Dev

Document.write(<script>)が予期しないトークン「ILLEGAL」をスローします

分類Dev

JavaScriptのwindow.locationとdocument.locationの違いは何ですか?

分類Dev

Call Elastic search from shell script for indexing pdf document

分類Dev

Share a Drive document without notifying user with Google Apps Script

分類Dev

Change document title when title has been changed by another script

分類Dev

Error trying to save Word document as PDF in PowerShell script

分類Dev

<script async> vs document.getElementsByTagName( 'script')[0] .insertBeforeなど?

分類Dev

How to write a script which executes certain commands on terminal?

Related 関連記事

  1. 1

    <script> document.write( '<base href =“' + document.location + '” />'); </ script>

  2. 2

    <script> document.cookie = "humans_21909 = 1"; document.location.reload(true)</ script>

  3. 3

    document.location.hrefとdocument.locationの違いは何ですか?

  4. 4

    Load external script which has document.write using ReactJS

  5. 5

    document.locationのObject.observe

  6. 6

    IE11は、document.location.hrefまたは$(location).attr( "href")を使用して現在のURLを取得できません

  7. 7

    javascript document.write( "<base href =" ">"); 動作しない

  8. 8

    document.location.href =を実行した後、JQueryを使用して要素にクラスを追加します

  9. 9

    What is the '?' in a href when calling a php script?

  10. 10

    $ _SESSION ["name"] = "<script> document.write(name)</ script>";を使用せずにjs変数をphpに保存する方法

  11. 11

    document.write()で書き込むときに<script>タグを分割する理由

  12. 12

    document.createElement( "script")を同期的に

  13. 13

    Why is $(document).ready needed after the <script> tag?

  14. 14

    Invisible script tag in HTML document with websockets code in it

  15. 15

    Here-document not working properly on shell script

  16. 16

    Write script to open browser at specific URL on login?

  17. 17

    LaunchAgent script can't write to external drive

  18. 18

    method to write in log files in a shell script

  19. 19

    check cpanel authorisation with perl script and write file

  20. 20

    Making PHP Script Automatically write to text file

  21. 21

    Crontabbed shell script not able to create/write to a file

  22. 22

    Document.write(<script>)が予期しないトークン「ILLEGAL」をスローします

  23. 23

    JavaScriptのwindow.locationとdocument.locationの違いは何ですか?

  24. 24

    Call Elastic search from shell script for indexing pdf document

  25. 25

    Share a Drive document without notifying user with Google Apps Script

  26. 26

    Change document title when title has been changed by another script

  27. 27

    Error trying to save Word document as PDF in PowerShell script

  28. 28

    <script async> vs document.getElementsByTagName( 'script')[0] .insertBeforeなど?

  29. 29

    How to write a script which executes certain commands on terminal?

ホットタグ

アーカイブ