Step 1. Written below code in your application.
<html>
<body>
<script>
function get_Cookie_Val (offset)
{
var end_string = document
.cookie.indexOf (";", offset);
if (end_string == -1)
end_string = document.cookie.length;
return unescape(document
.cookie.substring(offset, end_string));
}
function get_cookie (name)
{
var arg = name + "=";
var str_lngt = arg.length;
var cookie_length = document.cookie.length;
var i = 0;
while (i < cookie_length) {
var j = i + str_lngt;
if (document
.cookie.substring(i, j) == arg)
return get_Cookie_Val (j);
i = document.cookie.
indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}
function set_cookie (name, value)
{
var argv = set_cookie.arguments;
var argc = set_cookie.arguments.length;
var expires = (argc > 2)
? argv[2] : null;
var path = (argc > 3) ? argv
[3] : null;
var domain = (argc > 4) ? argv
[4] : null;
var secure = (argc > 5) ? argv[
5] : false;
document.cookie = name + "="
+ escape (value) +
((expires == null) ? ""
: ("; expires=" + expires.toGMTString())) +
((path == null) ? ""
: ("; path=" + path)) +
((domain == null) ?
"" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new
Date();
exp.setTime (exp.getTime() - 1);
var cval = get_cookie (name);
document.cookie = name + "="
+ cval + "; expires=" + exp.toGMTString();
}
</script>
<form name="demoForm"
onSubmit="
if(demoForm.Username.value.length != 0
) {
var expdate = new
Date ();
expdate.setTime(expdate.getTime() + (24 *
60
* 60 *
1000));
set_cookie('Demoname', demoForm.Username.value, expdate);
alert('Hey ' + demoForm.Username.value +
',
how is it going? Now all you have to do is click Enter
');
return false;
} else {
alert('You left the name field blank.');
return false;
}">
<center><p><font size=+1>Enter Your name Here
To Request Access : </font></font></i>
</b><input type="text"
name="Username" size=40
></p></center>
<center><p><input type="submit"
value="Submit Request"
><input type="button"
value="Enter"
onClick="
if(get_cookie('Demoname'
) == null)
alert('Did you submit request?')
else
window.open('j15b.htm'
, '_top')">
</form>
</body>
</html>
Step 2. Run the Application. Enter your name and click to Enter the site.
(追記) (追記ここまで)Others
Languages
Frameworks
Web / Design
Mobile Technology
Sql & Technology
R4R