在javascript中更改年龄验证框位置

时间:2013-12-27 23:15:54

标签: javascript html css splash-screen splash

目前我有一个Age Verification Splash页面,我有点失落。

我有一个工作脚本,如果未满18岁,会重定向到谷歌,并在18岁或以上时将您发送到主网站。

我没有处理过启动页面,所以这对我来说是新的。它引用我的css文件吗?我在那里添加任何CSS的东西吗?非常感谢任何帮助。

网站是Vaporwrx.com(目前它全部为白色,“盒子”位于左上角。我需要将盒子移动到中心并更改背景颜色或添加图像。这是我工作的代码与

    <head>

    <script language="javascript">
    function checkAge()
    {
    /* the minumum age you want to allow in */
    var min_age = 18;

    /* change "age_form" to whatever your form has for a name="..." */
    var year = parseInt(document.forms["age_form"]["year"].value);
    var month = parseInt(document.forms["age_form"]["month"].value) - 1;
    var day = parseInt(document.forms["age_form"]["day"].value);

    var theirDate = new Date((year + min_age), month, day);
    var today = new Date;

    if ( (today.getTime() - theirDate.getTime()) < 0) {


    window.location.href = "http://www.google.com/"

    return false;
    }
    else {
    /* set the age check cookie here so it can be found on all pages (if they have  cookies         enabled!) */
    return true;
    }
    }
    </script>

    **** PLEASE ENTER YOUR BIRTHDAY ****

    <form action="http://www.vaporwrx.com/default.asp" method="post" name="age_form">
    Day : <select name="day">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    </select>

    Month : <select name="month">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    </select>

    Year : <select name="year">
    <option>2013</option>
    <option>2012</option>
    <option>2011</option>
    <option>2010</option>
    </select>

    <input type="submit" name="senddate" value="Go" onClick="return checkAge()"> 
    </head>

1 个答案:

答案 0 :(得分:0)

在表单

之前添加

<link rel=StyleSheet href="../css/reports.css" type="text/css" media=screen>

将您的表格包裹在div ...

<div id="age_form">  <!--form stuff --> </div>

然后在CSS文件中:

#age_form
{
    margin-left: auto; 
    margin-right: auto; 
    background-color:#00ff00;
}