最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Allow user to change URL in window.open() - Stack Overflow

programmeradmin4浏览0评论

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 = ";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?

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.&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?

Share Improve this question edited Jul 29, 2016 at 13:05 Si8 asked Feb 14, 2014 at 20:02 Si8Si8 9,23522 gold badges119 silver badges223 bronze badges 1
  • possible duplicate of change url of already opened popup – joeytwiddle Commented Aug 21, 2015 at 1:09
Add a ment  | 

2 Answers 2

Reset to default 3

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

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.'
, '_blank'
);

The jsfiddle.

发布评论

评论列表(0)

  1. 暂无评论