1

I'm using the jquery UI dialog box, and I have some radio buttons and a submit button.

If the 1st button is selected, and the user clicks the button, I want a new window to open just like if there was a href tag like:

<a href="http://www.example.com" target="_blank">Click</a>

So in the click event so far I am at:

$(this).click(function (e) {
   e.preventDefault();
});

Is it possible to do this? (has to work in IE)

5
  • w3schools.com/jsref/met_win_open.asp Commented Feb 14, 2013 at 16:35
  • window.open does not work ? Commented Feb 14, 2013 at 16:35
  • @Archer it is w3fools.com Commented Feb 14, 2013 at 16:36
  • 1
    @Archer There's lots of misinformation on w3schools, so we avoid referencing it.
    – Barmar
    Commented Feb 14, 2013 at 16:39
  • @Barmar Okay - I didn't know it had that reputation. I don't use it myself. It was just the first result in google. I checked it and it looked okay. Another thing I've learnt today :) Commented Feb 14, 2013 at 16:46

2 Answers 2

5

This here should help. Look at the fiddle: http://jsfiddle.net/pcDbX/

$('#link').click(function () {

     window.open('http://www.example.com','mywindow','width=400,height=200')

});

Also this link will show you what parameters you can use: http://www.pageresource.com/jscript/jwinopen.htm

And here are some common attributes to pass to the window.open():

  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 the 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.

1
0

Try

   $('#buttonid').click(function(){

      window.open('http://www.google.com', '_blank');

   });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.