2016-09-04 12 views
0

ブラウザのウィンドウでURLの座標(x、y)をWebサイトに取得する方法はありますか?ブラウザのリンクの座標(x、y)を取得する方法は?

私はすでにinspect要素を表示しようとしましたが、私が探しているものを見つけることができませんでした。

+0

ご質問はありますか? –

+0

私は、ブラウザのウィンドウ内のリンクの座標(x、y)を取得することを意味します。 @@!悪い英語のため申し訳ありません、私は質問を編集しました。 – AlphaWolf

+0

pythonはサーバー側ですので、お手伝いできません。ブラウザのJavascriptが移動する方法かもしれません。あなたはjavascriptで質問にタグを付けるべきです –

答えて

0

私はあなたが求めていることを理解していると思います。この場合、リンクがクリックされたときにIDで識別されています。前者はリンクの動作を実行しますが、両方のメソッドが必要な処理を行います。これは、ブラウザーのコンテンツ内の位置のみを提供し、画面上の絶対位置は指定しないことに注意してください。

<p>I put some text here for the experience of having <a id="link" href="somewhere.com" onclick="findMe(this)">this link</a> in a paragraph which will put it on the page and I can adjust the size of the browser window to show that it moves around and changes the location.</p> 
<p><button onclick="findTag()">Click</button> 
<script> 
    function findMe(tag) 
    { 
    alert(tag.offsetLeft+", "+tag.offsetTop); 
    } 

    function findTag() 
    { 
    //so this would identify the <a> without following the href 
    findMe(document.getElementById("link")); 
    } 
</script> 
関連する問題