Javascript redirect - New Window

2019-04-29 14:16发布

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>

2条回答
▲ chillily
2楼-- · 2019-04-29 14:33
<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

查看更多
老娘就宠你
3楼-- · 2019-04-29 14:44

Here you go: Jsfiddle Example

function opennewtab(url){
    var win = window.open(url, '_blank');
}
查看更多
登录 后发表回答