Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Open a new window in onClick event from code

Status
Not open for further replies.

sirnose1

Programmer
Nov 1, 2005
133
US
I have this code that when "preview" is clicked, the email opens in a new window. That works fine. However when "Send" is clicked, the user gets a confirmation window that they will be sending an email and cant be undone. I need to open this in a new window. I have added target=_blank a couple of times and its not working. What am I missing here?

vb.net code:

strEmailLink = "<a target=_blank href=/ADMIN/new/PRIVATE/GAINSHARE/group_growth/SupplierEmail.aspx?index=Preview&userName=" & e.Row.Cells(11).Text & "&memName=" & Server.UrlEncode(e.Row.Cells(11).Text) & "&memberInfo=" & Server.UrlEncode(e.Row.Cells(5).Text) & ">Preview</a>"
strEmailLink += " | <a target=_blank href=""#"" onclick = ""if (confirm('Are you sure you want to Send this email to " & e.Row.Cells(11).Text & "? This action cannot be undone. "
strEmailLink += "Click OK or CANCEL to return to the page.'))window.location='SupplierEmail.aspx?index=Send&userName=" & e.Row.Cells(11).Text & "'; return false"">Send</a>"

 
1. always post the final rendered code as it makes it easier to understand in the context of Javascript. Js never sees the Vb code only the final html code.

2. Use the open() method to open a new window instead of the location method.
Code:
window.open('SupplierEmail.aspx?index=Send&userName=" & e.Row.Cells(11).Text & "')
Note that popup blockers may block the new window from opening in most cases.

3. Always post code between [ignore]
Code:
[/ignore] tags. Makes it easier to read.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Though if it IS for use in email clients, as the variable name implies, just about ALL of them will block javascript 'popup' windows.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top