利用javascript的escape实现asp页面,实现asp.net中的server.urlencode.

<script language="JavaScript">
function winopen(url,width,height)
{
     var newurl,arrurl;
     if(typeof(url) == "undefined" || url == "")

<script language="JavaScript">
function winopen(url,width,height)
{
     var newurl,arrurl;
     if(typeof(url) == "undefined" || url == "")
     {
         return ;
     }
     else
     {
         if(url.indexOf("?") == -1)
         {
             newurl = url;
         }
         else
         {
             newurl = url.substring(0,url.indexOf("?")+1);
             arrurl = url.substring(url.indexOf("?")+1).split("&");
             for(var i =0;i<arrurl.length;i++)
             {
                 newurl += arrurl[i].split("=")[0] + "=" + escape(arrurl[i].split("=")[1]) + "&";
             }
             newurl = newurl.substring(0,newurl.length-1);
         }
     }
     if(typeof(width) != "number" || typeof(height) != "number")
     {
         window.open(newurl);
     }
     else
     {
         window.open(newurl,"","width=" + width + ",height=" + height);
     }
}
</script>
<a href="#" onclick="winopen(‘/test.aspx?title=网页’);">Links</a>

发表评论

电子邮件地址不会被公开。 必填项已用*标注