Si8 Si8 - 4 months ago 12
jQuery Question

Allow user to change URL in window.open()

I have the following code which opens a new window when a user clicks on a button:

$('.loginButton').click(function () {
var strString = $("#medlineSearch").val()
var strSearch = "http://google.com&query=";
var url = strSearch + strString;
alert(strSearch+strString);
var windowName = $(this).attr('id');
window.open(url, windowName, "height=750,width=1250,scrollbars=1,resizable=1,location=1");
// custom handling here
return false;
});


What I am looking to do is allow the user to enter something else in the address bar which seems to be read only.

Is there any way to change that?

Answer

If you want to be able to change it, set the target to _blank.

This will prevent the new page to open as popup, but as new page.

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

The jsfiddle.

Comments