using target=_blank in a gridview row javascript event
e.Row.Attributes.Add("onclick", location='" + e.Row开发者_StackOverflow社区.Cells[5].Text + "'");
works fine but I want the new page to open in a new window.
e.Row.Attributes.Add("onclick", "target=_blank location='" + e.Row.Cells[5].Text + "'");
nothing happens. The source code inside the tablerow is:
onclick="target=_blank location='http://www.something.com'"
Do I need to do a window.open to accomplish this? If so, can someone provide syntax as my efforts to that effect have not been successful.
Thanks.
onclick is looking for javascript... target, used in this fashion, is an attribute for an anchor tag...
(IMO) window.open is your best/easiest option.
onclick="window.open('http://www.something.com', 'mywindow')"
unless you turn that row item into an anchor:
<a href="http://www.something.com" target=_blank>Click Me</a>
you can do this by creating a template column and building the link based on the data returned and the template it needs to fit into.
open (URL, windowName[, windowFeatures])
Changing the features of the Popup You can control the features of the popup using the last argument to the window.open method. The following code opens a window with a status bar and no extra features.
window.open ("http://www.javascript-coder.com","mywindow","status=1");
The code below opens a window with toolbar and status bar.
window.open ("http://www.javascript-coder.com", "mywindow","status=1,toolbar=1");
The table shows the features and the string tokens you can use:
status The status bar at the bottom of the window.
toolbar The standard browser toolbar, with buttons such as Back and Forward.
location The Location entry field where you enter the URL.
menubar The menu bar of the window
directories The standard browser directory buttons, such as What’s New and What’s Cool
resizable Allow/Disallow the user to resize the window.
scrollbars Enable the scrollbars if the document is bigger than the window
height Specifies the height of the window in pixels. (example: height=’350′)
width Specifies the width of the window in pixels.
Information obtained at: Using the Window Open Method.
精彩评论