I'm making some buttons, that when one is clicked, it will send a message of "1" to another page. If button 2 is pressed, it will again send a message to the other page saying "2" or something. How can I accomplish this, so it will send a message to another page and I can go there to review the message or number? Can this work in javascript or jquery?
Asked
Active
Viewed 1,523 times
0
-
1what is "another page"? I ask, because as a browser, I have no idea what that is. – Mike 'Pomax' Kamermans Jan 30 '16 at 22:38
-
Like, I'm on index.html, and it will go to codes.html or something. – Akidus Jan 30 '16 at 22:45
-
can use localStorage and when new page loads check what is stored. Really need more details on use case – charlietfl Jan 30 '16 at 22:46
-
no, seriously. The browser doesn't know "other pages". The one you're on is all you get. Another page, as far as the browser is concerned, is a completely different website. So you'll need to do data synchronization. That means either websockets via a server (so you can do data pushing), or storing domain-specific information for syncing via localStorage (but then you'll need to constantly check localStorage and that eats into the cpu), etc. etc – Mike 'Pomax' Kamermans Jan 30 '16 at 22:47
1 Answers
1
Hard to answer without knowing how you navigate between pages.
Assuming that you use window.location
, in your onbuttonclick method, you could just append urlparameters like window.location = othersite.html?message=1
and then read it on that other site as mentioned here: How to get the value from the GET parameters?
-
-
You are missing a very important thing in your question: how is your navigation from page1 to page2 done? as you heared in the other comments there is no such thing like "pages". There is only 1 page. The user can navigate through links and you can hook into navigation with window.location. – Jens Feb 01 '16 at 20:46
-
Well, when you press a button, it will go to the pictures.html page, intead of index.html. – Akidus Feb 02 '16 at 00:43
-
There are still at least 2 ways: by or by onclick="window.location='pictures.html'", however, in both you could append a ?message=1 parameter and read it on the next page – Jens Feb 07 '16 at 00:12