www.webdeveloper.com
Results 1 to 2 of 2

Thread: need help creating and storing variables in cookie(s)

Hybrid View

  1. #1
    Join Date
    Mar 2011
    Posts
    2

    need help creating and storing variables in cookie(s)

    I'm new to javascript and need to know how to store variables in cookies so that I can later use them in php code.

    Here is the basic javascript I want to use:
    Code:
    function alertSize() {
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
      window.alert( 'Width = ' + myWidth );
      window.alert( 'Height = ' + myHeight );
    }
    Now, I want to save myWidth and myHeight in a cookie(s) but I don't know how to. The window.alert() will only be for testing purposes and will not be needed in the final code. I also need to know if the codes need to be in certain sections such as <head>, etc. Do I need to change any lines of code or need to add anything.

    Thanks in advance for your help.

  2. #2
    Join Date
    Mar 2011
    Posts
    2
    ??

Thread Information

Users Browsing this Thread

There are currently 3 users browsing this thread. (0 members and 3 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles