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

javascript - Setting a page to open in a new borderless window - Stack Overflow

programmeradmin5浏览0评论

Is there a way to force a page to open in a new window all the time regardless of the link used to open it? By adding something to the header perhaps? I know about target-"new" and window.open() but i want the page itself to always open as a new window with no toolbars or scrollbars shown even if the link used to open it is generic () with no target="new" or similar specified. I am only concerned with Internet explorer.

Thanks in advance.

Is there a way to force a page to open in a new window all the time regardless of the link used to open it? By adding something to the header perhaps? I know about target-"new" and window.open() but i want the page itself to always open as a new window with no toolbars or scrollbars shown even if the link used to open it is generic () with no target="new" or similar specified. I am only concerned with Internet explorer.

Thanks in advance.

Share Improve this question asked Mar 23, 2017 at 1:38 Admir OAdmir O 811 silver badge3 bronze badges 2
  • no. What you are talking about is taking control of a browser even before it opens which means access to stuff the web page has no business accessing. Window.open, etc is the best you can hope for – Bindrid Commented Mar 23, 2017 at 1:50
  • Add target attr to your links and thats the best and the best solution – Sajed Commented Mar 23, 2017 at 1:58
Add a ment  | 

1 Answer 1

Reset to default 5

I actually found a nice example here

here's the snippet (you might need to type this in a text editor and open that html file first because I don't seem to be getting it working on StackOverflow alone)

I hope this is what you are looking for.

<html>
<head>
<title>Opening Multiple Popup Windows</title>

<script language="javascript">
<!--//
function myPopup(url,windowname,w,h,x,y){
window.open(url,windowname,"resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=n o,width="+w+",height="+h+",left="+x+",top="+y+"");
console.log("Opening: " + windowname);
}
//-->
</script>
</head>
<body>
<!-- Inside the parenthesis the order goes URL, window name, width, height, position from left, position from top-->
<!-- Note that by giving each popup window a different name each page will open in a seperate popup window-->
<a href="javascript:myPopup('http://www.cnn.', 'CNN','300','300','10','300')">Open popup 1</a>
<br>
<a href="javascript:myPopup('http://example.', 'Example.','300','300','100','300')">Open popup 2</a>
<br>
<a href="javascript:myPopup('http://www.nbc.', 'NBC','300','300','200','500')">Open popup 3</a>
</body>
</html>

发布评论

评论列表(0)

  1. 暂无评论