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)
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<!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>
<meta http-equiv="Content-Type" content="text/html;&n ......
keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space
keycode 33 = Prior
keycode 34 ......
正则
<script>
function checkvalue(){
if(document.Form.content.value.replace(/\s/g,"")=="")
{
alert("内容不能为空!");
document.addForm.content.focus();
return false;
}
document.addForm.submit();
return ......
要在你的网页中使用 JavaScript ,你首先必须要知道该将它放在哪儿。其实很简单,只要在你的网页(HTML文件)中插入
<SCRIPT> 和 </SCRIPT> 标记对,你就可以在这两个标记队之间插入你的 JavaScript 代码了:
<script>
alert("Hello world!");
</script>
另外,你也可以将 Ja ......