js获取url参数来替换iframe链接地址

<html>

  <body>

                                                 <asp:HiddenField ID="HiddenField1" runat="server" />
                                                <iframe id="fram"
                                                    width="550" height="670" frameborder="0" style="margin-left: 10px;"></iframe>
                                                </form>

  </body>

</html>

 

 

 

                    <script type="text/javascript" language="javascript">
                    function GetRequest() {
                       var url = location.search; //获取url中"?"符后的字串
                       var theRequest = new Object();
                       if (url.indexOf("?") != -1) {
                          var str = url.substr(1);
                          strs = str.split("&");
                          for(var i = 0; i < strs.length; i ++) {
                             theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
                          }
                       }
                       return theRequest;
                    }
                   
                    window.onload = function(){
                        var Request = new Object();
                        Request = GetRequest();
                        var ct_id,substd_id;
                        ct_id = Request['ct_id'];
                        substd_id = Request['substd_id'];
                        var scrStr = "http://usercenter.pudong.gov.cn:8229/qlgk/xzcfpowerstd_detail.jsp?sj_dir=XzcfDetail&psid=" + ct_id + "&substdid=" + substd_id + "";
                        document.getElementById("fram").src = scrStr;
                    };

posted @ 2013-08-20 10:50  Amir_Blogs  阅读(1082)  评论(0编辑  收藏  举报