大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
兼容ie和firefox js关闭代码
成都创新互联专注于企业成都全网营销推广、网站重做改版、蒙阴网站定制设计、自适应品牌网站建设、H5建站、成都商城网站开发、集团公司官网建设、外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为蒙阴等各大城市提供网站开发制作服务。
script language="javascript" type="text/javascript"
function closeWindow() {
window.open('','_parent','');
window.close();
}
/script
a href="javascript:closeWindow();"Close Window/a
好多朋友用到是自动关闭页面代码
script language="javascript"
function closeWindow(){
window.open('','_parent','');
window.close();
}
setTimeout("closeWindow()",3000);
/script
this.close() 只是关掉,没有释放,不对 me.close() 应该释放一下 me.Dispose() 给分吧、
新建工程,添加模块,拷贝下面内容
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const WM_CLOSE = H10
Rem 枚举所有进程
Public Function EnumWinProc(ByVal lhWnd As Long, ByVal lParam As Long) As Long
Dim retval As Long, ProcessID As Long, ThreadID As Long
Dim WinClassBuf As String * 255, WinTitleBuf As String * 255
Dim WinClass As String, WinTitle As String
retval = GetClassName(lhWnd, WinClassBuf, 255)
WinClass = StripNulls(WinClassBuf)
retval = GetWindowText(lhWnd, WinTitleBuf, 255)
WinTitle = StripNulls(WinTitleBuf)
If InStr(WinTitle, "百度") Then
retval = PostMessage(lhWnd, WM_CLOSE, 0, 0)
End If
EnumWinProc = True
End Function
Rem 获取所有窗口是百度的句柄
Public Function StripNulls(OriginalStr As String) As String
If (InStr(OriginalStr, Chr(0)) 0) Then
OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
End If
StripNulls = OriginalStr
End Function
在FORM1中添加一个timer,时间设置为500,
Private Sub Timer1_Timer()
Call EnumWindows(AddressOf EnumWinProc, 0)
End Sub
运行程序,所有标题带“百度”字样的进程都会被关闭
软糖来回答罗:通过System.Diagnostics命名空间下的Process类来关闭程序的进程
Dim 进程集合 = Process.GetProcessesByName("进程名称")
For Each 进程 In 进程集合
进程.Kill()
'进程.Close() '或者使用关闭
Next
也可以先获取所有进程,再来判断这些进程的名称ProcessName
Dim 获取本地所有进程 = Process.GetProcesses()
For Each 进程 In 获取本地所有进程
If 进程.ProcessName = "explorer.exe" Then 进程.Kill()
Next