0

私はすでにユーザーエージェントを送信しています:

<input type='hidden' name='user-agent' value='<?php echo $_SERVER['HTTP_USER_AGENT']; ?>'/><input type="submit" value="Send User Agent" />

私は調査を行いましたが、残念ながら機能しないコードがいくつかあります。自分自身に助けを求めているのは、問題を抱えている他の人々です。

PHPフォームを使用して画面解像度を送信するにはどうすればよいですか?

4

4 に答える 4

1

JavaScript 経由で画面解像度を入力して送信する必要があります。誰でも隠しフィールドの値を変更できるので、これは安全な方法ではありません...しかし、うまくいきます:

// Fill in forms with screen resolution (jQuery)
$('#screenWidth').val(screen.width);
$('#screenHeight').val(screen.height);

そして、いくつかの非表示フィールドを使用するだけです。

<input type="hidden" name="screenWidth" id="screenWidth"/>
<input type="hidden" name="screenHeight" id="screenHeight"/>
于 2012-04-24T11:18:37.113 に答える
1

As other people have said, the screen object works. Just saying "It doesn't work" doesn't help with finding the problem out. If you have jQuery correctly loaded, it will just work.

screen.width + "x" + screen.height

This returns "1280x1024" in my case.

See http://jsfiddle.net/KVQM4/ for an example of it working. If you can create something similar to show how it doesn't work, or give us a bit more information as to the error.

于 2012-04-24T11:45:57.500 に答える
1

サーバーIMHOから画面解像度を取得できません...フォームをレンダリングさせてから、javascriptを使用してフォーム入力を正しい情報で更新できます

HTML

<input id="browser-resolution" type="hidden" name="resolution" value="">

その後、スクリプトとして

<script>
  document.getElementById('browser-resolution').value = screen.width + "x" + screen.height;
</script>

編集:フィッフルを追加

于 2012-04-24T11:19:14.970 に答える
1

前の例は機能するはずです。

Javascript

document.getElementById('debug').value = screen.width + 'x' + screen.height;

エラーが発生していますか?どのブラウザを使用していますか? OS?

于 2012-04-24T11:29:19.580 に答える