Friday, April 10, 2009

[JavaScript] Re: Javascript to find Operating System.

VBscript is to identify windows version and display ip address information.

------------------------------------

Visit http://aiaiai.com for more groups to joinYahoo! Groups Links

<*> To reply to this message, go to:
http://groups.yahoo.com/group/JavaScript_Official/post?act=reply&messageNum=16658
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/JavaScript_Official/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:JavaScript_Official-digest@yahoogroups.com
mailto:JavaScript_Official-fullfeatured@yahoogroups.com

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/JavaScript_Official/

<*> To unsubscribe from this group, send an email to:
JavaScript_Official-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Re: [JavaScript] JavaScript Help?

After researching and reading about cookies I got my problem solved. I thought I would post my solution. It was simple.

Here are the cookie scripts I made work.

Write cookie

noDays = 30;
function setCookie(name, value, expires) {
if (!expires) expires = new Date();
document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";
}
var expdate = new Date ();
expdate.setTime(expdate.getTime() + noDays*24* 60 * 60 * 1000);

setCookie('myCookie','ForLogin',expdate)

*** Change myCookie to the name you want to give to your cookie.

Read cookie with redirect

go_to = "webpage.com";
function getCookie(name)
{
var cookies = document.cookie;
if (cookies.indexOf(name) != -1)
{
window.location = go_to;
}
else
{
return false; // the cookie couldn't be found! it was never set before, or it expired.
}
}
getCookie("myCookie");

*** replace webpage.com to the redirect page you want to go to.

--- In JavaScript_Official@yahoogroups.com, Paul <paul@...> wrote:

>
>
>
>
> That's pretty ordinary code, unfortunately. Certainly, having a function
> called readCookie that actually WRITES a cookie is going to be confusing at
> best.
>
> I recommend that you do a Google search for: javascript cookies tutorial
>
> The very first hit that I got -
> http://www.elated. com/articles/ javascript- and-cookies/ - appears to offer
> all the code you're likely to need to do what you want to do. In
> particular, it provides a function to set a cookie and one to get (read) a
> cookie, plus a simple example.
>
> Regards, Dave S
>
> ----- Original Message -----
> From: "Paul" <paul@thewebparrots. com>
> To: <JavaScript_Official @yahoogroups. com>
> Sent: Sunday, April 05, 2009 1:55 PM
> Subject: [JavaScript] JavaScript Help?
>
> >
> > Hi everyone,
> > I'm new to the group and I am hoping for a little help. I'm trying to
> > make a webpage that has website "Terms and Conditions" and also a button
> > saying you are over 18. I wanted to use a cookie so the next time the
> > same user access the web address they will be redirected to the main
> > site.
> >
> > I created an index.html page with an iFrame. The iFrame holds the
> > "Terms and Conditions" text with a checkbox to be checked if you accept
> > the TOC. Under the iFrame I have two buttons for Over 18 and Under 18.
> > When you check the box in the iFrame a cookie is set. I wanted the
> > cookie to be set this way in case the user selects the over 18 button
> > but didn't select the checkbox in the iFrame. If this case happens I
> > want to alert them to accept the TOA at the bottom of the page.
> >
> > I've never really used cookies in the past but I am somewhat familiar
> > with JS. The cookie scripts I've researched have me confused. A few
> > years ago I took a JavaScript class and I used a script from that class
> > to set and read my cookie.
> >
> > // page to go to if cookie exists
> > go_to = "mainSite/index. php <http://www.perlscri ptsjavascripts. com> ";
> >
> > // number of days cookie lives for
> > num_days = 60;
> > function ged(noDays){
> > var today = new Date();
> > var expr = new Date(today.getTime( ) + noDays*24*60* 60*1000);
> > return expr.toGMTString( );
> > }
> >
> > function readCookie(cookieNa me){
> > var start = document.cookie. indexOf(cookieNa me);
> > if (start == -1){
> > document.cookie = "myCookie=yes; expires=" + ged(num_days) ;
> > } else {
> > window.location = go_to;
> > }
> > }
> >
> > readCookie(" myCookie" );
> >
> > Here is my problem. Because I'm using one html page to set the cookie
> > (the one in the iFrame) and another to read the cookie and redirect I've
> > been trying to break this script into two parts. I've also been all
> > over the web looking at other resources but I can't find the scripts I
> > need.
> >
> > Can someone give me a little help? I need a script for one page that
> > sets the cookie (myCookie) and another one that reads the cookie and
> > gives me a redirect.
> >
> > I was able to remove the redirect from the above script and use it in
> > the iFrame page. The modified script sets the cookie (myCookie) fine
> > without errors. When I try to use this script with a redirect on the
> > index page it keeps setting another cookie. If I remove the ged function
> > it still writes a session cookie which won't let me check for the
> > checkbox.
> >
> > Maybe I'm going about this the wrong way. This is the only way I could
> > think of to find out if a checkbox from another page was checked or not.
> > I'm using a onClick event handler on the checkbox.
> >
> > Thanks in advance for any help offered.
> >
> > Paul
> >
> >
> >
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------ --------- --------- ------
> >
> > Visit http://aiaiai. com for more groups to joinYahoo! Groups Links
> >
> >
> >
> >
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>


------------------------------------

Visit http://aiaiai.com for more groups to joinYahoo! Groups Links

<*> To reply to this message, go to:
http://groups.yahoo.com/group/JavaScript_Official/post?act=reply&messageNum=16656
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/JavaScript_Official/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:JavaScript_Official-digest@yahoogroups.com
mailto:JavaScript_Official-fullfeatured@yahoogroups.com

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/JavaScript_Official/

<*> To unsubscribe from this group, send an email to:
JavaScript_Official-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/