读书人

iframe中获取file绝对路径有关问题d

发布时间: 2012-09-11 10:49:03 作者: rapoo

iframe中获取file绝对路径问题,document.selection.createRange()为空
var obj = document.getElementById("file");
obj.select();
obj.blur();
var path = document.selection.createRange().text;

这段代码放在iframe中时,path获取的路径为空?这是为什么呢?

[解决办法]
WebForm1

HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebForm1.aspx.cs" Inherits="WebForm1" %><!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 runat="server"><title>WebForm1</title></head><body>    <form id="form1" runat="server">    <div id="divbody">        <iframe src="WebForm2.aspx" id="ifram1" frameborder="0" ></iframe>    </div>    </form></body></html> 

读书人网 >JavaScript

热点推荐