3

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?

Si8
  • 9,141
  • 22
  • 109
  • 221
  • possible duplicate of [change url of already opened popup](http://stackoverflow.com/questions/10774211/change-url-of-already-opened-popup) – joeytwiddle Aug 21 '15 at 01:09

2 Answers2

2

You cannot change the url in popup window.


Read change url of already opened popup
Trick to do so

open console and type location.href='http://link.com'

Community
  • 1
  • 1
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
  • The thing is, I want the address bar to be free text. I am thinking it is not possible to do that. – Si8 Feb 14 '14 at 20:07
  • this actually changes the page... i'm trying take screenshots of a page not yet in production (release) but the URL is a staging URL which won't do for release documentation – Michael May 05 '17 at 16:17
2

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.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325