开发者

Read cookie values through javascript or jquery

I have called one asp page inside the iframe

You can check here: https://www.fiestacups.com/ProductDetails.asp?ProductCode=DUMMY

If customer select font and sel开发者_高级运维ect clip art image or upload image for clip art then I have store all that values in cookies.

Now I want to get that cookies values in java-script variable on the another page.

How can I do this? Please help me....


Using jquery cookies plugin is quiet simple:

// read 
$.cookie('whatever')

// write 
$.cookie('whatever', 'my whatever value')


function get_cookie ( cookie_name )
            {
                var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

                if ( results )
                    return ( unescape ( results[2] ) );
                else
                    return null;
            }
            function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
            {
                var cookie_string = name + "=" + escape ( value );

                if ( exp_y )
                {
                    var expires = new Date ( exp_y, exp_m, exp_d );
                    cookie_string += "; expires=" + expires.toGMTString();
                }

                if ( path )
                    cookie_string += "; path=" + escape ( path );

                if ( domain )
                    cookie_string += "; domain=" + escape ( domain );

                if ( secure )
                    cookie_string += "; secure";

                document.cookie = cookie_string;
            }
 set_cookie ( "iframeURL", "hello" );

var test=get_cookie ( "iframeURL" );


on another page you can use to read the value stored in cookie :-

var value = document.cookie("name_of_cookie");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜