Javascript函数在主页面或新窗口上打开URL

Javascript Function to Open a URL on the main page or new window

本文关键字:窗口 URL 函数 主页 新窗口 Javascript      更新时间:2023-09-26

我在我网站首页的iframe中使用了一些javascript。有一个幻灯片功能,当用户滑动一张图片时,它会打开一个指向另一个网站的链接,但此时它会打开iframe中的链接,所以看起来很有趣。

这是使用atm:的js代码

    var unlock = function()
{
    //$("#gfx").animate({backgroundPosition: '0 40'}, 400, '', function()
    //{
        $("#gfx-bottom").animate({bottom: -100}, 300);
        $("#gfx-top").animate({top: -100}, 300, '', function()
        {});    
        $("#iphone-inside").fadeOut("normal", function(){window.location="http://www.urlimtryingtolinkto.com";});                                 
    //});

使用window.top.

var unlock = function()
{
    //$("#gfx").animate({backgroundPosition: '0 40'}, 400, '', function()
    //{
        $("#gfx-bottom").animate({bottom: -100}, 300);
        $("#gfx-top").animate({top: -100}, 300, '', function()
        {});    
        $("#iphone-inside").fadeOut("normal", function(){window.top.location="http://www.urlimtryingtolinkto.com";});                                 
//});

对于新窗口,请使用window.open()

var unlock = function()
{
    //$("#gfx").animate({backgroundPosition: '0 40'}, 400, '', function()
    //{
        $("#gfx-bottom").animate({bottom: -100}, 300);
        $("#gfx-top").animate({top: -100}, 300, '', function()
        {});    
        $("#iphone-inside").fadeOut("normal", function(){window.open("http://www.urlimtryingtolinkto.com");});                                 
    //});