在加载框架的iPad中的window.open()不起作用 [英] window.open() in an iPad on load of a frame does not work

查看:386
本文介绍了在加载框架的iPad中的window.open()不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改使用Morten的JavaScript树菜单的网站,以便在使用Adobe Reader插件设置的框架中显示PDF。

I am trying to modify a site that uses "Morten's JavaScript Tree Menu" to display PDFs in a frames set using the Adobe Reader plug-in.

iPad框架没用,所以我想在新标签中打开PDF。不想弄乱树状菜单我以为我可以在查看器框架中打开的网页中使用JavaScript来打开带有PDF的新选项卡。

On the iPad the frame is useless, so I want to open the PDF in a new tab. Not wanting to mess with the tree menu I thought I could use JavaScript in the web page being opened in the viewer frame to open a new tab with the PDF.

我是使用$(document).ready(function()中的window.open()来打开新选项卡中的pdf。问题是window.open()不想在iPad中工作。

I am using window.open() in $(document).ready(function() to open the pdf in the new tab. The problem is that window.open() does not want to work in the iPad.

HTML的正文通常如下所示...

The body of the HTML normally looks like this...

<body>
    <object data="MypdfFileName.pdf#toolbar=1&amp;navpanes=1&amp;scrollbar=0&amp;page=1&amp;view=FitH" 
    type="application/pdf" 
    width="100%" 
    height="100%">
    </object>
</body>

我把它更改为只有这样的div ......

I changed it to only have a div like this...

<body>
    <div class="myviewer" ></div>
</body>

然后使用以下脚本......

Then used the following script...

$(document).ready(function() {
    var isMobile = {
        Android : function() {
            return navigator.userAgent.match(/Android/i) ? true : false;
        },
        BlackBerry : function() {
            return navigator.userAgent.match(/BlackBerry/i) ? true : false;
        },
        iOS : function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
        },
        Windows : function() {
            return navigator.userAgent.match(/IEMobile/i) ? true : false;
        },
        any : function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
        }
    };

    if(isMobile.any()) {
        var file = "MypdfFileName.pdf";
            window.open(file);
    }else {
        var markup = "<object   data='MypdfFileName.pdf#toolbar=1&amp;navpanes=1&amp;scrollbar=0&amp;page=1&amp;view=FitH' type='application/pdf' width='100%' height='100%'></object>";
        $('.myviewer').append(markup);
    };
});

除了iPad上的window.open()外,其余功能都有效。如果我切换widow.open()可以在计算机上正常工作。在另一个项目中,我通过onclick函数在iPad上成功使用window.open()。

Everthing works except for window.open() on the iPad. If I switch things around widow.open() works fine on a computer. In another project I am using window.open() successfully on the iPad from an onclick function.

我尝试使用计时器功能。我还尝试在div中添加onclick函数并发布click事件。在这两种情况下,他们都在电脑上工作,而不是iPad。我很难过。

I tried using a timer function. I also tried adding an onclick function to the div and posting a click event. In both cases they worked on a computer but not an iPad. I am stumped.

我知道在树状菜单框架中处理ipad会更有意义,但是代码太复杂了我无法弄清楚在哪里放置/修改onclick事件。

I know it would make more sense to handle the ipad in the tree menu frame, but that code is so complex I can't figure out where to put/modify the onclick event.

有没有办法更改对象以便在新标签页中打开?

Is there a way to change the object so that it opens in a new tab?

是否有人熟悉Mortens树菜单代码,可以告诉我如何调用点击事件,以便在新标签中打开pdf而不是在框架中打开页面?

Is anyone familiar enough with Mortens Tree Menu code that can tell me how to channge the on click event so that it opens the pdf in a new tab instead of opening a page in the frame?

谢谢

推荐答案

Safari可能会阻止弹出窗口。这意味着,当用户点击时,会执行一项操作,window.open是否有效,但不会发生。

probably Safari tries to block popups. That means that when the user clicks, does an action, window.open works, but not when it "happens".

这篇关于在加载框架的iPad中的window.open()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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