Reputation: 15626
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.
Upvotes: 0
Views: 13449
Reputation: 1751
Have you tried this?
<script type="text/javascript">
window.open ('test.htm','_self',false)
</script>
Upvotes: 1
Reputation: 9110
Well that's not possible technically, it also depends on browser tab settings, window settings and third party tab manipulation plugins or addons.
OP has cleared the confusion of all through his comment 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
})
Upvotes: 4
Reputation: 3141
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.
Upvotes: 0