×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

What's the difference between the following codes?(asp)

Code1:
<%
empid=Server.URLEncode("你好")
%>
<a href="javascript:newURL('EqpHist.asp?empid=<%=Server.URLEncode(empid)%>')">a link</a>

Code2:
<%
empid=Server.URLEncode("你好")
%>
<a href="#" onclick="newURL('EqpHist.asp?empid=<%=Server.URLEncode(empid)%>')">a link</a>

In both case,newURL is a javascript function

function newURL(URL)
{
var change = document.MainForm.hidChange.value
if (change == "TRUE") {
response = window.confirm("<%=msg%>")
if (response == false)
return
}
window.location.href = URL
}
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / What's the difference between the following codes?(asp)
    Code1:
    <%
    empid=Server.URLEncode("你好")
    %>
    <a href="javascript:newURL('EqpHist.asp?empid=<%=Server.URLEncode(empid)%>')">a link</a>

    Code2:
    <%
    empid=Server.URLEncode("你好")
    %>
    <a href="#" onclick="newURL('EqpHist.asp?empid=<%=Server.URLEncode(empid)%>')">a link</a>

    In both case,newURL is a javascript function

    function newURL(URL)
    {
    var change = document.MainForm.hidChange.value
    if (change == "TRUE") {
    response = window.confirm("<%=msg%>")
    if (response == false)
    return
    }
    window.location.href = URL
    }
    • Code 1 is using javascript protocol, code 2 is using DHTML.
    • 个人觉得, 如果是写程序就选2, 如果是面试问题就说两者没区别.
    • 我在IE6和IE7里测试的结果:code1把"你好"变成了乱码.code2可以正确完成参数的传递. Firefox里面两个都正确. 哪位大侠知道其中的道理吗?