允许用户在window.open()中更改URL

时间:2014-02-14 20:02:48

标签: javascript jquery html

我有以下代码,当用户点击按钮时会打开一个新窗口:

$('.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;
});

我要做的是允许用户在地址栏中输入其他似乎只读的内容。

有什么方法可以改变吗?

2 个答案:

答案 0 :(得分:2)

您无法在弹出窗口中更改网址。

<小时/> 阅读change url of already opened popup
诀窍

打开控制台并输入location.href='http://link.com'

答案 1 :(得分:2)

如果您希望能够更改它,请将目标设置为_blank

这会阻止新页面以弹出方式打开,而是作为新页面打开。

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

jsfiddle

相关问题