【求助】关于Asp.net页面间传递参数的问题

liuyunzhi82 2013-06-26 05:44:38
我有一个纯html页面index.htm在里面嵌套了一个ifram

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<iframe src="http://localhost:2690/UserLoginForCms.aspx" width="230" frameborder="0" scrolling="no">
</iframe>
</td>
</tr>
</table>

在index.htm页面中的body中的onload事件加入了
<body style="margin: 0 auto;" onload="displayScreenSize()">

javascript的代码如下

<head>
<script language="javascript">
function displayScreenSize() {
document.getElementById("sWidth").value = document.documentElement.clientWidth;
document.getElementById("sHeight").value = document.documentElement.clientHeight;
}
</script>
</head>

现在我想做的是将“sWidth”和“sHeight”这两个Hidden的值传给UserLoginForCms.aspx页面,现在我能想到的方法是这样的

<iframe src="http://localhost:2690/UserLoginForCms.aspx?swidth=sWidth的value值&sHieght=sHeight的value值" width="230" frameborder="0" scrolling="no">

请问我应该怎么做才能取到那两个控件的value值,并把它们作为问号后面的变量参数呢?
如果还有什么其他简单的方法也请指教一二,屏幕的宽度与高度值我只能在这个母页面取才正常,所以这两个值只能从这个页面传出去。
...全文
123 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyunzhi82 2013-06-27
  • 打赏
  • 举报
回复

<!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>
        <script language="javascript">
            function displayScreenSize() {
                document.getElementById("sWidth").value = document.documentElement.clientWidth;
                document.getElementById("sHeight").value = document.documentElement.clientHeight;
            }
</script>
</head>
<body  onload="displayScreenSize()">
    <input type="hidden" id="sWidth" runat="server"/>
    <input type="hidden" id="sHeight" runat="server" />
    <div>
        <table width="1000" border="0" cellpadding="0" cellspacing="0" align="center">
            <tr>
                <td>
                   <iframe src="#" name="mainFrame" id="mainFrame" scrolling="no"
                            width="230" frameborder="0" onload="initFrame();">
                    </iframe>
                </td>
            </tr>
            </table>
      </div>
      <script type="text/javascript">
          function initFrame() {
              var w = document.getElementById("sWidth").value;
              var h = document.getElementById("sHidth").value;
              var url = "http://localhost:2690/UserLoginForCms.aspx?swidth=" + w + "&sHieght=" + h;
              $('mainFrame').attr('src', url);
          }
      </script>
</body>
</html>
这个是我整个页面的结构,还是取不出来值,水平有限。。。。虚心求教
吴青峰 2013-06-27
  • 打赏
  • 举报
回复
给<iframe src="http://localhost:2690/UserLoginForCms.aspx" width="230" frameborder="0" scrolling="no"> </iframe> 加个ID,然后在你加载的时候, 直接displayScreenSize(){}将这里面的代码变为下面的代码看看。 function displayScreenSize() { var swidth= document.documentElement.clientWidth; var sHeight= document.documentElement.clientHeight; document.getElementById("ID").src="http://localhost:2690/UserLoginForCms.aspx?swidth=sWidth&sHieght=sHeight"; }
  • 打赏
  • 举报
回复
引用 6 楼 liuyunzhi82 的回复:
[quote=引用 3 楼 Chinajiyong 的回复:]

  <iframe src="#" style="text-align: left" name="mainFrame" id="mainFrame"
                        width="100%" height="100%" frameborder="0" scrolling="auto" onload="initFrame();">
                    </iframe>

var url=...//拼接
$('#mainFrame').attr('src', url);
你的方法我试了,可是iframe的onload事件是不执行,不知道是为什么?

 <script type="text/javascript">
function initFrame() {
var w = document.getElementById("sWidth").value;
var h = document.getElementById("sHidth").value;
var url = "http://localhost:2690/UserLoginForCms.aspx?swidth=" + w + "&sHieght=" + h;
alert(url);
$('mainFrame').attr('src', url);
}
</script>
这是我写的方法,放在<head>里面或者<iframe>的先都不执行[/quote]我有带 initFrame这样的方法名称么 而且这个要放在尾部,尾部懂么?
liuyunzhi82 2013-06-27
  • 打赏
  • 举报
回复
引用 3 楼 Chinajiyong 的回复:

  <iframe src="#" style="text-align: left" name="mainFrame" id="mainFrame"
                        width="100%" height="100%" frameborder="0" scrolling="auto" onload="initFrame();">
                    </iframe>

var url=...//拼接
$('#mainFrame').attr('src', url);
你的方法我试了,可是iframe的onload事件是不执行,不知道是为什么?

 <script type="text/javascript">
function initFrame() {
var w = document.getElementById("sWidth").value;
var h = document.getElementById("sHidth").value;
var url = "http://localhost:2690/UserLoginForCms.aspx?swidth=" + w + "&sHieght=" + h;
alert(url);
$('mainFrame').attr('src', url);
}
</script>
这是我写的方法,放在<head>里面或者<iframe>的先都不执行
看见彩虹 2013-06-26
  • 打赏
  • 举报
回复
引用 4 楼 liang_show 的回复:
[quote=引用 楼主 liuyunzhi82 的回复:] 我有一个纯html页面index.htm在里面嵌套了一个ifram

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>                                                       
              <td>
                  <iframe src="http://localhost:2690/UserLoginForCms.aspx" width="230"                  frameborder="0"  scrolling="no">
                  </iframe>
               </td>
          </tr>
 </table>
在index.htm页面中的body中的onload事件加入了
<body style="margin: 0 auto;" onload="displayScreenSize()">
javascript的代码如下

<head>
<script language="javascript">
   function displayScreenSize() {
        document.getElementById("sWidth").value = document.documentElement.clientWidth;
        document.getElementById("sHeight").value = document.documentElement.clientHeight;
    }
</script>
</head>
现在我想做的是将“sWidth”和“sHeight”这两个Hidden的值传给UserLoginForCms.aspx页面,现在我能想到的方法是这样的

 <iframe src="http://localhost:2690/UserLoginForCms.aspx?swidth=sWidth的value值&sHieght=sHeight的value值" width="230" frameborder="0"  scrolling="no">
请问我应该怎么做才能取到那两个控件的value值,并把它们作为问号后面的变量参数呢? 如果还有什么其他简单的方法也请指教一二,屏幕的宽度与高度值我只能在这个母页面取才正常,所以这两个值只能从这个页面传出去。
把ifame加上一个id 如:id="ifam": 然后在页面的尾部 加上一个javascript代码:
<script type="text/javascript">
   var w=document.getElementById("sWidth").value;
var h=document.getElementById("sHidth").value;
     document.getElementById("ifam").src = "http://localhost:2690/UserLoginForCms.aspx?swidth=w&sHieght=h";
 </script>
[/quote] 楼上是不是拼接错了,
"http://localhost:2690/UserLoginForCms.aspx?swidth=" + w + "&sHieght=" + h;
我怎么试好像也是这样拼接的
  • 打赏
  • 举报
回复
引用 楼主 liuyunzhi82 的回复:
我有一个纯html页面index.htm在里面嵌套了一个ifram

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>                                                       
              <td>
                  <iframe src="http://localhost:2690/UserLoginForCms.aspx" width="230"                  frameborder="0"  scrolling="no">
                  </iframe>
               </td>
          </tr>
 </table>
在index.htm页面中的body中的onload事件加入了
<body style="margin: 0 auto;" onload="displayScreenSize()">
javascript的代码如下

<head>
<script language="javascript">
   function displayScreenSize() {
        document.getElementById("sWidth").value = document.documentElement.clientWidth;
        document.getElementById("sHeight").value = document.documentElement.clientHeight;
    }
</script>
</head>
现在我想做的是将“sWidth”和“sHeight”这两个Hidden的值传给UserLoginForCms.aspx页面,现在我能想到的方法是这样的

 <iframe src="http://localhost:2690/UserLoginForCms.aspx?swidth=sWidth的value值&sHieght=sHeight的value值" width="230" frameborder="0"  scrolling="no">
请问我应该怎么做才能取到那两个控件的value值,并把它们作为问号后面的变量参数呢? 如果还有什么其他简单的方法也请指教一二,屏幕的宽度与高度值我只能在这个母页面取才正常,所以这两个值只能从这个页面传出去。
把ifame加上一个id 如:id="ifam": 然后在页面的尾部 加上一个javascript代码:
<script type="text/javascript">
   var w=document.getElementById("sWidth").value;
var h=document.getElementById("sHidth").value;
     document.getElementById("ifam").src = "http://localhost:2690/UserLoginForCms.aspx?swidth=w&sHieght=h";
 </script>
EnForGrass 2013-06-26
  • 打赏
  • 举报
回复

  <iframe src="#" style="text-align: left" name="mainFrame" id="mainFrame"
                        width="100%" height="100%" frameborder="0" scrolling="auto" onload="initFrame();">
                    </iframe>

var url=...//拼接
$('#mainFrame').attr('src', url);
  • 打赏
  • 举报
回复
window.parent.document.all.隐藏域的名称 看看能否得到
EnForGrass 2013-06-26
  • 打赏
  • 举报
回复
你可以用js去拼接 Iframe的src值

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧