-1

javascriptを使用してあるphpページから別のphpページに変数を渡し、ページをロードせずにその出力を取得する方法はありますか?変数はjavascriptを使用してのみ渡す必要があることに注意してください。私

4

1 に答える 1

0

If you really want to avoid using PHP you can try 3 methods:

  1. Saving data to cookies.
  2. Saving data to local storage. (not relyable because of compatibility)
  3. Passing variables between windows. (may not match your problem)

1. Cookies

This is easyest and most relyable method. But be aware - user can edit and view data. You should google yourself some articles about that, tahie this one (http://www.quirksmode.org/js/cookies.html) for starter to understand the topic.

2. Local storage

Some browsers may have this utility disabled or not implemented at all. Advantage of this is, that, unlike cookies, this data are not sent with HTTP request headers so you can save some traffic. Google again. There is nothing I can tell you about theese what google can't.

3. Passing variables between windows

This only works for very specific case - when you have two windows and one of them is opened via window.open() function. This function returns new window handle.

var child_window = window.open(/*params*/);
child_window.document.title = "Hello world!";

But still you should consider using AJAX to save variables on server and retrieve them from here.

于 2013-02-03T12:45:28.413 に答える