开发者

open new browser window within dialog ajax call - jquery NOT popup

I am stumped. How do I open a link "go" in this situation using jquery?

Opened a dialog and when click on activate button. The link should open a new browser window / tab the same as clicking on a link "go" with target=_blank.

<div id="dialog">
<a href="http://stackoverflow.com" target="_blank" >go</a>
</div>
<script type="text/javascript">
$( "#dialog" ).dialog({buttons: {
"Activate": function(event) {
    $.get("404.html").error(function(){ 
    $("#dialog a").click(); //doesnt work
    $("#dialog a").trigger("click"); //doesnt work
    window.open("http://stackoverflow.com",'_blank'); //opens a popup, not what i ne开发者_C百科ed
    window.location.href //is not what i need since its in same window/tab
       });
    }
}});
</script>


You were partially correct. You do use window.open(strUrl, strWindowName[, strWindowFeatures]);. However, you have to fill in more attributes.

window.open('link','mywindow','width='+ $(window).width() +',height='+ $(window).height() +',toolbar=yes, 
location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, 
resizable=yes')

Here is good documentation on how to use window.open: https://developer.mozilla.org/en-US/docs/Web/API/Window.open

Below is a short list of the attributes you can use:

  1. width=300 Use this to define the width of the new window.

  2. height=200 Use this to define the height of the new window.

  3. resizable=yes or no Use this to control whether or not you want the user to be able to resize the window.

  4. scrollbars=yes or no This lets you decide whether or not to have scrollbars on the window.

  5. toolbar=yes or no Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).

  6. location=yes or no Whether or not you wish to show the location box with the current url (The place to type http:// address).

  7. directories=yes or no Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...).

  8. status=yes or no Whether or not to show the window status bar at the bottom of the window.

  9. menubar=yes or no Whether or not to show the menus at the top of the window (File, Edit, etc...).

  10. copyhistory=yes or no Whether or not to copy the old browser window's history list to the new window.


you can try window.open('http://stackoverflow.com', '_newtab');. Keep in mind this behaviour is mostly controlled by the browser so the results may vary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜