日期:2014-05-16  浏览次数:20335 次

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>