admin管理员组文章数量:1304100
I have a button:
<button>Click</button>
I want click it and open a new window in the same page, I bind the click event an event handle:
$('button').click(function () {
var newurl="http://" + window.location["host"] + ";
window.open(newurl, '_parent');
})
But is always open in new tab or new window, the second parameter I have try _self
_top
.
I even have try window.location.href(newurl)
So how can I solve this problem?Does it matter with browser or OS? I view it in Mac OS's firefox and chrome.
I have a button:
<button>Click</button>
I want click it and open a new window in the same page, I bind the click event an event handle:
$('button').click(function () {
var newurl="http://" + window.location["host"] + ";
window.open(newurl, '_parent');
})
But is always open in new tab or new window, the second parameter I have try _self
_top
.
I even have try window.location.href(newurl)
So how can I solve this problem?Does it matter with browser or OS? I view it in Mac OS's firefox and chrome.
Share Improve this question edited Feb 20, 2014 at 23:04 tshepang 12.5k25 gold badges97 silver badges139 bronze badges asked Jun 28, 2012 at 10:54 hh54188hh54188 15.7k35 gold badges116 silver badges191 bronze badges 3- What you ask is impossible. "New window" is mutually exclusive with "same page." It sounds like you really just want to change the URL in the current window/tab. – Matt Ball Commented Jun 28, 2012 at 10:55
- Do you wish to open the url in the current window? I am not sure whether or not I understand your question right. – EricG Commented Jun 28, 2012 at 10:56
- 1 @EricG: Yes, you understand is right – hh54188 Commented Jun 28, 2012 at 10:58
4 Answers
Reset to default 4Well that's not possible technically, it also depends on browser tab settings, window settings and third party tab manipulation plugins or addons.
Update
OP has cleared the confusion of all through his ment below his question, this is what you need to set a new url for current window:
$('button').click(function () {
var newurl="http://" + window.location["host"];
window.location.href = newurl; // or simply window.location
})
window.location =newurl;
will open a new window replacing the parent
Have you tried this?
<script type="text/javascript">
window.open ('test.htm','_self',false)
</script>
If you mean you want to replace the current page, window.location = newLocation;
will do.
If you want a modal popup, try JQuery UI Dialog.
本文标签: javascriptHow to open a new window in the same pageStack Overflow
版权声明:本文标题:javascript - How to open a new window in the same page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741780768a2397295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论