javascript 获取file表单全路径
在ie6中对于<input type="file"
/>通过obj.value是可以获取客户端选择文件的全路径的,但是到ie7就只能获取文件名,这对于onchange事件立即显示图片会有问题,可以用js方法解决
具体代码如下:
<html>
<head>
<title>get file input full path</title>
<script
language='javascript'>
function getFullPath(obj)
{
if(obj)
{
//ie
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
obj.select();
return document.selection.createRange().text;
}
//firefox
else
if(window.navigator.userAgent.indexOf("Firefox")>=1)
{
if(obj.files)
相关文档:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>间隔滚动图片</title>
<meta http-equiv= ......
正则
<script>
function checkvalue(){
if(document.Form.content.value.replace(/\s/g,"")=="")
{
alert("内容不能为空!");
document.addForm.content.focus();
return false;
}
document.addForm.submit();
return ......