欢迎光临
我们一直在努力

以前收集的一些资料—如何使用ASP动态生成页面的祯结构

建站超值云服务器,限时71元/月

                  让你的asp控制frame
我以前说过使用response.redirect是不能够跳到另外一个frame的把,呵呵,那么我们怎么来使用asp来控制frame呢?
下面将提供一个方法来解决这个问题。
事实上,一共有两种方法控制asp生成的html显示在哪一个frame中。
简单的是设置html的form元素的基本标志即可。这个方法可以解决大多数简单情况下的页面定位问题。
这个方法大家应该都见过,我就不详细说明了。
但是问题是当出现一些复杂的情况时,我们怎么来控制redirect的跳转呢?
下面将给出一个例子程序(其实是个很有用的例子程序)
它将动态生成frame并且可以在你的网站上增加4个搜索引擎(如果你确实
想把这段代码加入到你的网站上的话,呵呵)
用fp随便写一个html页面,文件名为frsearch.htm分为两个frame
左边的frame里面有一个用来输入查询条件的文本框(name为searchtopic),
再外加4个checkbox(表示4个查询站点
内容分别是:这四个单选框的name分别为altavista,mskb, news, avdf,4个的value都为on) ,
其中还专门给mskb(ms knowledge base)做一个下拉框,用来选择topic用的,
name是searcharea),还有两个单选框,name都是viewtype,最后是一个提交按钮。
然后在你的页面中加入下面两句话。
<base target="_top">
<form action="dosearch.asp">

文件名为dosearch.asp
<%
    searchtopic = request.form ("searchtopic")
    searchtopic = server.urlencode(searchtopic)
    只给微软的kb用的
    searcharea = request.form ("searcharea")           
    frame的显示形式
    viewtype = request.form("viewtype")                

    你要显示的frame数目
    frcount = 0                       
    if request.form("altavista") = "on" then
            avurl = "http://www.altavista.yellowpages.com.au/cgi-bin/telstra?pg=q&what=web&fmt=.&q=" & searchtopic
            frcount = 1
    end if
    if request.form("mskb") = "on" then
            msurl = "http://search.microsoft.com/searchbin/kb/mts_search.idq?hdr=@kbarea&scope=/kb/articles/&tmplt=mts_search&swr=f&sort=rank[d]&purl=/kb&pfx=kb&base=kb&sl=null&kbd=" & searcharea & "&maxp=25&maxr=100&sz=" & searchtopic
            frcount = frcount + 1
    end if
    if request.form("avdf") = "on" then
            avdfurl = "http://www.gui.com.au/gcgi/glance?tp=search.gl&query=" & searchtopic & "&case=on&whole=on&area=all+issues&errors=0+%28exact+match%29&maxfiles=10&maxlines=10"
            frcount = frcount + 1
    end if
    if request.form("news") = "on" then
            newsurl = "http://www.gui.com.au/gcgi/news_search?query=" & searchtopic &"&maxresults=50&rtype=1"
            frcount = frcount + 1
    end if  
    
    if viewtype = "frame" then
        动态生成frame
            splitpct = fix(100/frcount)
            pcts = cstr(splitpct)
            if frcount = 1 then
                    pctstr = pcts & "%"
            end if
            if frcount > 1 then
                    pctstr = pctstr & "," & pcts & "%"
            end if
            if frcount > 2 then
                    pctstr = pctstr & "," & pcts & "%"
            end if
            if frcount = 4 then
                    pctstr = pctstr & "," & pcts & "%"
            end if
    end if
%>

<script language="javascript" for="window" event="onload()">
        <!–
          <%if avurl <> "" then %>
                window.open ("<%=avurl %>")
          <% end if %>
          <%if avdfurl <> "" then %>
                window.open ("<%=avdfurl %>")
          <% end if %>
          <%if newsurl <> "" then %>
                window.open ("<%=newsurl %>")
          <% end if %>
          <%if msurl <> "" then %>
                window.open ("<%=msurl%>")
          <% end if %>
          
          window.location.href = "frsearch.htm"
          –>
</script>

<html>
<head>
<title>4个搜索引擎</title>
</head>

<%if viewtype = "frame" then %>

<frameset cols="20%,80%">
    <frame src="searchside.htm">
    <frameset rows="<%=pctstr%>">
        <%if avurl <> "" then %>
                <frame src="<%=avurl%>" name="altavista">
        <% end if %>
        <%if avdfurl <> "" then %>
                <frame src="<%=avdfurl%>" name="avdf">
        <% end if %>
        <%if newsurl <> "" then %>
                <frame src="<%=newsurl%>" name ="news">
        <% end if %>
        <%if msurl <> "" then %>
                <frame src="<%=msurl%>" name = "mskb">
        <% end if %>
    </frameset>
    <noframes>
    <body>
    <p>this web page uses frames, but your browser doesnt support them.</p>
    </body>
    </noframes>
</frameset>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 以前收集的一些资料—如何使用ASP动态生成页面的祯结构
分享到: 更多 (0)