2013-08-05 94 views
0

我创建了一个包含iframe的asp页面。 iframe包含表单,表单提交我想将iframe重定向到另一个页面。表单提交后重定向iframe

我已经尝试了这种方法:

//iframe content: 
<html> 
    <head> 
    <script type="text/javascript"> 
     function onformsubmit() 
     { 
     setTimeout(function() 
     { 
      $(top.document).find('#page').attr('src', 'page2.aspx'); 
     },1000); 
     } 
    </script>  
</head> 
<body> 
    <form id="form1" runat="server" onsubmit="onformsubmit()"> 
     ... 
     <div class="menubar"> 
      <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> 
      &nbsp; 
      <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> 
     </div> 
     ... 
    </form> 
    </body> 
</html> 

但遗憾的是它不工作。 我使用visual basic serverside;客户端我使用的是JavaScript。

+0

想想Crosspage发帖:http://msdn.microsoft.com/en-us/library/ms178139%28v=vs .100%29.aspx – Kangkan

回答

0
document.getElementId('iframe_name').src="http://anothersite.com/"; 

@benVG:等待......形式是的iframe,并提交后,你希望那相同的iframe到另一个网址?如果是这种情况,那么你只需要document.location.url = 'http://someurl.com'。如果情况属实,你根本不需要参考iframe。

+0

几乎与我写的 – benVG

+0

差不多,但不是真的一样:-)你试过了吗? – Locohost

+0

是的,但它不起作用... – benVG

0

请试试这个代码

setTimeout(function(){document.location.href = "www.google.com";},500); 

可能它会帮助你

+0

不幸的是这不起作用 – benVG