Sultan
Sultan

Reputation: 53

vb.net Open File - Chrome & IE

I've been having a nightmare getting a method to open a file working, until I tested the process in Chrome and discovered it worked so it can only be an issue within IE. Unfortunately some of the users will surely be using IE so I still need to resolve the issue. Here's what I've got:

   Protected Sub OpenFile(filePath As String) 

    If dlCvFlName Is Nothing Or dlCvFlPath Is Nothing Then
        lblError.Text = 'The Candidate does not have a CV uploaded'
    Else
        Dim script As String = "window.open('" & filePath & "', 'Popup', '_newtab');"
        Page.ClientScript.RegisterStartupScript(Me.[GetType](), "open", script, True)
    End If
End Sub

OpenFile("www.domain.com/file/document.doc")

When I run this in chrome the file is successfully opened, however absolutely nothing happens in IE...

Please help...?

Upvotes: 0

Views: 1528

Answers (1)

Darren Wainwright
Darren Wainwright

Reputation: 30737

I belive the issue is your _newtab name - this isn't typically supported.

Options should be:

_blank - URL is loaded into a new window. This is default

_parent - URL is loaded into the parent frame

_self - URL replaces the current page

_top - URL replaces any framesets that may be loaded

Remove _newtab and try again..

Also

Because the user isn't actually actioning this themselves - I.E you are injecting javascript to force a popup on page_load - the browsers popup blocker will surely intercept it.

You would be better off attaching the window.open method to a button and have javascript fire on the page, rather than posting back and injecting it.

Upvotes: 1

Related Questions