Ora*_*ind 0 javascript php forms cursor-position
基本上是问题的两个部分.
上述任何程序都涉及到javascript吗?如果是,请说明
第一个技巧只是一个预设值.当您单击该字段时,它具有一个检查的onclick函数.值是"在此处写下您的电子邮件".如果是这样,请清除该字段.如果什么都不做.
然后它有一个onblur函数检查,该字段为空.如果是这样,请在其中打印"在此处写下您的电子邮件".
第二个也是JavaScript.
这是一个包含这两个函数的Example页面
<html>
<script type="text/javascript">
function searchBox()
{
elem = document.getElementById("search");
if(elem.value == "Search...")
{
elem.value = "";
}
}
function searchBoxBlur()
{
elem = document.getElementById("search");
if(elem.value == "")
{
elem.value = "Search...";
}
}
function init()
{
document.getElementById("other_box").focus();
}
window.onload = init;
</script>
<body>
<input type="text" name="other_box" id="other_box" />
<input type="text" name="search" id="search" value="Search..." onclick="searchBox()" onblur="searchBoxBlur()" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)