页面加载时Javascript Window.open

时间:2011-12-20 04:20:30

标签: javascript vb.net

我在body onload事件上使用了JavaScript,我使用了这段代码:

function timeMsg()
{
    var t=setTimeout("mywindow()",1000);
}

function mywindow()
{
    var win = window.open('http://202.125.144.34:83/FDB_prog.aspx', '_blank','width=1 height=1 left=2000 top=2000');
    return true;
}

并且在页面加载时,使用此代码在我的网页中打开了一个pdf文件

Private Sub ReadPdfFile()
    Dim path As String = "C:\Inetpub\wwwroot\db\Files\rwservlet_reptest&report=sap_dashboard.pdf"
    Dim client As Net.WebClient = New Net.WebClient
    Dim buffer() As Byte = client.DownloadData(path)
    If (Not (buffer) Is Nothing) Then
        Response.ContentType = "application/pdf"
        Response.AddHeader("content-length", buffer.Length.ToString)
        Response.BinaryWrite(buffer)
    End If
End Sub 

当页面加载pdf文件打开并弹出窗口时,问题是当我重新打开callong pdf页面时弹出窗口打开。我想每次打开页面时打开

1 个答案:

答案 0 :(得分:1)

尝试类似

的内容
window.onload = timeMsg;

window.onload = function()
{
var t=setTimeout("mywindow()",1000); 
 // call other functions which you want to be called when window loads   
}