Обработка события обновления страницы с помощью javascript

Я нашел хитрое решение ... которое работает только в RelativeLayout. Нам нужно только поместить View над ListView и установить для просмотра интерактивный «true» и false для ListView

 <ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/listview
    android:clickable="false" />

<View
    android:layout_width="match_parent"
    android:background="@drawable/gradient_white"
    android:layout_height="match_parent"
    android:clickable="true"
    android:layout_centerHorizontal="true"
    android:layout_alignTop="@+id/listview" />
20
задан tiboo 20 October 2010 в 16:50
поделиться

2 ответа

Вы не хотите обновлять, вы хотите событие onbeforeunload.

http://msdn.microsoft.com/en-us/library/ms536907 (VS.85) .aspx

Пример кода из статьи

<HTML>
<head>
<script>
function closeIt()
{
  return "Any string value here forces a dialog box to \n" + 
         "appear before closing the window.";
}
window.onbeforeunload = closeIt;
</script>
</head>
<body>
  <a href="http://www.microsoft.com">Click here to navigate to 
      www.microsoft.com</a>
</body>
</html>
28
ответ дан 30 November 2019 в 00:27
поделиться

Самое близкое, что вы можете получить, это событие window.onbeforeunload :

window.onbeforeunload = function (e) {
    var e = e || window.event;

    // For IE and Firefox
    if (e) {
        e.returnValue = 'Leaving the page';
    }

    // For Safari
    return 'Leaving the page';
};

Важно отметить, что вам нужно вернуть строку из этой функции.

4
ответ дан 30 November 2019 в 00:27
поделиться
Другие вопросы по тегам:

Похожие вопросы: