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

html - Javascript redirect - New Window - Stack Overflow

programmeradmin0浏览0评论

I'm trying to create a re-direct using Javascript from inside a blank iframe that will direct to a URL inside a new window or tab.

More specifically, I'm trying to make a Facebook tab point to my company's webpage rather than load the page inside the tab's iframe which is not the same width as our web page.

Here is the redirect script I already have but it doesn't open the URL in a new window.

<script language="JavaScript">
<!--Redirect to 75th page
var time = null
function move() {
window.location = '.aspx'
}
timer=setTimeout('move()',0000)
//-->
</script>

Ok - This snippet will open a new window when the page loads but Chrome's pop-up blocker blocked it. I didn't think about this until now. Maybe I could have it load in a light window?

<script language="JavaScript">
<!--Redirect to 75th page
var time = null
function open_win()
{
window.open(".aspx", "_blank");
}

timer=setTimeout('open_win()',0000)
//-->
</script>

I'm trying to create a re-direct using Javascript from inside a blank iframe that will direct to a URL inside a new window or tab.

More specifically, I'm trying to make a Facebook tab point to my company's webpage rather than load the page inside the tab's iframe which is not the same width as our web page.

Here is the redirect script I already have but it doesn't open the URL in a new window.

<script language="JavaScript">
<!--Redirect to 75th page
var time = null
function move() {
window.location = 'http://philmontscoutranch.org/Camping/75.aspx'
}
timer=setTimeout('move()',0000)
//-->
</script>

Ok - This snippet will open a new window when the page loads but Chrome's pop-up blocker blocked it. I didn't think about this until now. Maybe I could have it load in a light window?

<script language="JavaScript">
<!--Redirect to 75th page
var time = null
function open_win()
{
window.open("http://philmontscoutranch.org/Camping/75.aspx", "_blank");
}

timer=setTimeout('open_win()',0000)
//-->
</script>
Share Improve this question edited Mar 5, 2013 at 22:59 user2132731 asked Mar 4, 2013 at 17:58 user2132731user2132731 811 gold badge1 silver badge4 bronze badges 3
  • 2 What's your specific question? – Aaron Kurtzhals Commented Mar 4, 2013 at 18:00
  • 1 Did you try window.open instead of window.location? w3schools.com/jsref/met_win_open.asp – Justin Bicknell Commented Mar 4, 2013 at 18:02
  • Will not chrome block any try to call window.open and assignments to window.location not triggered by user events? – Prusse Commented Aug 20, 2015 at 15:38
Add a comment  | 

2 Answers 2

Reset to default 9

Here you go: Jsfiddle Example

function opennewtab(url){
    var win = window.open(url, '_blank');
}
<html>
<head>
<script>
function open_win()
{
window.open("http://philmontscoutranch.org/Camping/75.aspx", "_blank");
}
</script>
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()">
</body>
</html>

Source

发布评论

评论列表(0)

  1. 暂无评论