Javascript重定向 - 新窗口 [英] Javascript redirect - New Window

查看:119
本文介绍了Javascript重定向 - 新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个空白的iframe来创建一个直接使用JavaScript的指令,这个指向一个新的窗口或标签的URL。

,我正在尝试将Facebook标签指向我公司的网页,而不是将页面加载到与我们的网页宽度不同的标签的iframe中。



这是我已经拥有的重定向脚本,但它不会在新窗口中打开该URL。

 < script language = JavaScript的 > 
<! - 重定向到第75页
var time = null
function move(){
window.location ='http://philmontscoutranch.org/Camping/75 .aspx'
}
timer = setTimeout('move()',0000)
// - >
< / script>






好的 - 这段代码会打开一个新窗口页面加载但Chrome的弹出窗口拦截器阻止了它。我直到现在才想到这个。也许我可以在一个光窗口中加载它?

 < script language =JavaScript> 
<! - 重定向到第75页
var time = null
函数open_win()
{
window.open(http://philmontscoutranch.org /Camping/75.aspx,_blank);
}

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


解决方案

在这里你可以: Jsfiddle示例

  function opennewtab (url){
var win = window.open(url,'_blank');
}


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>

解决方案

Here you go: Jsfiddle Example

function opennewtab(url){
    var win = window.open(url, '_blank');
}

这篇关于Javascript重定向 - 新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆