クラスのプロジェクトで作業しています。ページの読み込み時にポップアップを表示し、ユーザーが移動したときにポップアップを表示するjavascriptイベントが必要です。私はonload
とonunload
のイベントをHTMLに直接埋め込んで処理しようとしていますが、クロムとインターネットエクスプローラで動作しているようには見えません。アンロードメッセージしか表示されません。コードは以下の通りである:ページのJavaScriptのアラートページ終了時のロードとアラート
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>teest</title>
<!-- [if lt IE 9]>
<script src = "http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif] -->
<link rel="stylesheet" href="css/contact.css" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <!-- viewport tag configuration -->
<link rel="shortcut icon" href="img/favicon.ico" />
</head>
<body onload = "alert('Even if you aren't interested, please give our design some feedback as we would like to stay current.')" onunload = "alert('Thank you for your time and consideration!')">
<header class = "head">
<h1>
<img src="img/coa.png" display="inline-block" height="150px" float="left"/>
other stuff</h1>
<p>stuffsy</p>
</header>
可能な重複したり、文字列の正しい方法を認識します
にそれを変更する必要がありますページリフレッシュ?](http://stackoverflow.com/questions/13443503/run-javascript-code-on-window-close-or-page-refresh) – Bassie
[アンロードイベントのドキュメント](https:// developer .mozilla.org/ja-US/docs/Web/Events/unload)では、「UI interアクションは効果がありません(window.open、alert、confirmなど) "ので、onunloadでalertを使用することはできません。 – user2313067