I am using,
window.open("Download.php");
This file opens in a new tab for all browsers. But in Chrome, it opens in a new window. So I have tried:
window.open("Download.php",'_blank');
window.open("Download.php",'_new');
But it still opens in new window, not a tab. I don't know if this is a coding problem or default settings problem. I am using Chrome v31.0.1650.57 m.
I am using,
window.open("Download.php");
This file opens in a new tab for all browsers. But in Chrome, it opens in a new window. So I have tried:
window.open("Download.php",'_blank');
window.open("Download.php",'_new');
But it still opens in new window, not a tab. I don't know if this is a coding problem or default settings problem. I am using Chrome v31.0.1650.57 m.
Share edited Jan 4, 2015 at 17:29 unbindall 5141 gold badge14 silver badges29 bronze badges asked Nov 19, 2013 at 9:28 JEYASHRI RJEYASHRI R 4521 gold badge5 silver badges17 bronze badges 3- stackoverflow./a/4907854/1400370 – Jamie Taylor Commented Nov 19, 2013 at 9:33
- possible duplicate of Open url in new tab using javascript – JJJ Commented Nov 19, 2013 at 9:39
- I have tried. But still problem is there.Any other way ? I put my code in AJAX success side. – JEYASHRI R Commented Nov 19, 2013 at 10:13
2 Answers
Reset to default 1You can try:
var tab=window.open("Download.php",'_blank');
tab.focus();
Steps to verify
create a html file with markup:
<html>
<body>
<script>
function newTab(){
var tab=window.open("http://conceptf1.blogspot./2013/11/javascript-closures.html",'_blank');
tab.focus();
}
</script>
<a href="#" onclick="newTab()">Open Tab</a>
</body>
</html>
Open it in chrome and click the link.
Short answer: you can't. At least for now, the browser vendors view this as something that should strictly be left to users to define for themselves. You set your target to something that should be a new window, and the browser will use the user's preferences to decide whether it opens as a new window or a new tab.
Long answer: There's a CSS property that would do this on the HTML side, but none of the browsers support it. According to the proposal, you'd use target-new: tab
for links that you explicitly want to open in a new tab, and target-new: window
for those you want to open in a new window. I don't know of any DOM proposals to do something analogous to this on the JavaScript side.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744810053a4595003.html
评论列表(0条)