Public Class ScriptHelper Public Shared Function GetViewControlScript(ByVal controlName As String) As String
Dim script As String
script = vbCrLf
script += "<script language=""javascript"">" & vbCrLf
script += "function ViewObj(objName)" & vbCrLf
script += "{" & vbCrLf
script += "var obj = document.all.item(objName);" & vbCrLf
script += "if (obj != null)" & vbCrLf
script += "{" & vbCrLf
script += "obj.scrollIntoView();" & vbCrLf
script += "obj.focus();" & vbCrLf
script += "}" & vbCrLf
script += "}" & vbCrLf
script += "function ToDo()"
script += "{" & vbCrLf
script += [String].Format("setTimeout " & "(" & """ViewObj" & "(" & "'{0}')"",1000);" & vbCrLf, controlName) script += "}" & vbCrLf script += "window.onload = ToDo;" & vbCrLf
script += "</script>"
Return script End FunctionEnd Class
Dim script As String
script = vbCrLf
script += "<script language=""javascript"">" & vbCrLf
script += "function ViewObj(objName)" & vbCrLf
script += "{" & vbCrLf
script += "var obj = document.all.item(objName);" & vbCrLf
script += "if (obj != null)" & vbCrLf
script += "{" & vbCrLf
script += "obj.scrollIntoView();" & vbCrLf
script += "obj.focus();" & vbCrLf
script += "}" & vbCrLf
script += "}" & vbCrLf
script += "function ToDo()"
script += "{" & vbCrLf
script += [String].Format("setTimeout " & "(" & """ViewObj" & "(" & "'{0}')"",1000);" & vbCrLf, controlName) script += "}" & vbCrLf script += "window.onload = ToDo;" & vbCrLf
script += "</script>"
Return script End FunctionEnd Class
并请热心者帮忙注释以下,我对次懂的很少<script language=""javascript"">
function ViewObj(objName)
{
var obj = document.all.item(objName);
if (obj != null)
{
obj.scrollIntoView();
obj.focus();
}
}
function ToDo()
{
String.Format("setTimeout("ViewObj('{0}')",1000), controlName);
} window.onload = ToDo</script>
不过这需要支持script,并且你对DHTML编程要比较了解。
通过向web 窗体中插入javascript ???
程序先在服务器端运行,生成某些你需要的 JavaScript。然后再在客户端运行此 JavaScript
有Ecma的标准,