English 中文(简体)
窗口:没有在iPad工作
原标题:window.onbeforeunload not working on the iPad?

是否有任何人知道<代码>是否在上 在iPad和(或)在使用时有不同的方式支持活动?

我试着大量的事情,似乎像on beforeunload事件从未在iPad(Safari browser)上发生。

具体地说,这是我所尝试的:

  • window.onbeforeunload = function(event) { event.returnValue = test ; }
  • window.onbeforeunload = function(event) { return test ; }
  • (both of the above together)
  • window.onbeforeunload = function(event) { alert( test ) ; }
  • (all of the above functions but inside <body onbeforeunload="...">

所有这些工作都是关于FF和 Safari的,但不是关于iPad的。

此外,我刚刚在装满该页之后做了以下工作:

alert( onbeforeunload  in window);
alert(typeof window.onbeforeunload);
alert(window.onbeforeunload);

结果是:

  • true
  • object
  • null

因此,浏览器确实拥有这些财产,但出于某种原因,它没有发射。

我试图绕过该网页的方式是,点击背和前方纽州,在顶楼进行权 go搜索,改变地址栏的位置,并点击书记。

是否有任何人想到什么? 我非常赞赏任何投入。

增 编

问题回答

贾瓦语的这个范围对我来说是关于Safari语和 Chrome语以及 desktop/lap/其他浏览器:

var isOnIOS = navigator.userAgent.match(/iPad/i)|| navigator.userAgent.match(/iPhone/i);
var eventName = isOnIOS ? "pagehide" : "beforeunload";

window.addEventListener(eventName, function (event) { 
    window.event.cancelBubble = true; // Don t know if this works on iOS but it might!
    ...
} );

我发现,上载荷事件确实发生火灾。 它的行为有些奇怪;无论你在活动背后的职能中,在新网页装上背景后,实际上都会运行(你可以告诉它,但服务器的伐木将显示它有)。

更奇怪的是,如果你在上载上确认()电话,而且用户点击了一条连接,去其他地方,你就在做生意。 然而,如果用户关闭iPad Safari browser tab,则上载(未上载)活动将发生火灾,但你确认()会作为回应而间接取消。

确实只有 Apple果知道,但我的猜测是,他们故意无法在流动游艇上发挥这种功能,因为这种功能往往被冲破碎的特性所利用,使你能够留在现场或播许多色情/广告窗户。

网页上有网页www.Kit上的名bug。 我认为,这在最新的 Chrome5号星座中是固定的,但是,单Pad的浏览器很有可能是从一个没有固定装置的WebKit的版本中产生的。

http://code.google.com/p/chromium/issues/detail?id=4422” rel=“nofollow noretiger”>,《相关 Chromebug报告

卸载前活动没有移动电话的支持。 参看以下所有辅助活动清单:

前面的卸载不在名单上!





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签