By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,710 Members | 1,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,710 IT Pros & Developers. It's quick & easy.

How to make Bgcolor changer save choice using cookies?

P: 10
Expand|Select|Wrap|Line Numbers
  1. <div style="cursor: pointer; opacity: 1; position: fixed; right: 10px; top: 5px;">
  4. <script type="text/javascript">
  5. function bgChange(bg)
  6. {
  8. }
  9. </script>
  10. <table border="1" height="20" style="width: 300px;"><tbody>
  11. <tr> <td bgcolor="white" onclick="bgChange('')">
  12. </td><td bgcolor="#699AB8" onclick="bgChange('#699AB8')">
  13. </td><td bgcolor="#000000" onclick="bgChange('#000000')">
  14. </td><td bgcolor="#FF00FF" onclick="bgChange('#FF00FF')">
  15. </td><td bgcolor="#006400" onclick="bgChange('#006400')">
  16. </td><td bgcolor="#FF6600" onclick="bgChange('#FF6600')">
  17. </td><td bgcolor="#480082" onclick="bgChange('#480082')">
  18. </td><td bgcolor="#dc143c" onclick="bgChange('#dc143c')">
  19. </td><td bgcolor="#D4E3EA" onclick="bgChange('#D4E3EA')">
  20. </td><td bgcolor="#B40404" onclick="bgChange('#B40404')">
  21. </td><td bgcolor="#9A2EFE" onclick="bgChange('#9A2EFE')">
  22. </td><td bgcolor="#236c95" onclick="bgChange('#236c95')">
  25. </td></tr>
  26. </tbody></table>
  27. </div>

this's Background Color Changer .. but it no save visitor choice .. if i choosed red color .. it's ok .. but when i refresh i no see red color .. i see original one again .. So ..

How to make Bgcolor changer save choice usig cockies ??
Apr 16 '12 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 5K+
P: 8,639
for java cookies youíd need Java (thatís actually a different language), but Iím not sure whether Java applet have their own cookies Ö

however you have the choice to store data in regular cookies or the new Web Storage using JavaScript.
Apr 16 '12 #2

P: 10
Sp what java i add now to make it save cockies ?
Apr 16 '12 #3

Expert Mod 5K+
P: 8,639
I don’t know Java. this is the JavaScript forum.
Apr 16 '12 #4

P: 10
can you help me with javascript cockies to do save color ?
Apr 17 '12 #5

Expert Mod 5K+
P: 8,639
I haven’t used cookies for a while but IIRC setting data works by
Expand|Select|Wrap|Line Numbers
  1. document.cookie = "key=value";
reading is a bit more complicated as you get all key-value pairs as string. [more info]
Apr 17 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.