http://low-cost-travel.lk6.co/test109.php
■test109.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="ja"> <head> <title>jquery ipop_multi.jsのサンプル</title></html> ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー ■test109.js<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="./test109.js"></script> <script type="text/javascript"> $(function(){ /*検索ダイアログの表示イベントのフック*/ $('#open1').click(function() { /*検索ダイアログ表示*/ $("#mado1").ipop(); } ); /*画面遷移の直前にダイアログの状態をcookieに保存*/ $(window).on("beforeunload",function(){ /*ダイアログは見えてる?*/ if($('#mado1').css('display') == 'block') { /*表示中状態を保存*/ setCookie("OPEN","OPEN"); } else { /*消えているので削除*/ setCookie("OPEN",""); } }); $(function(){ /*cookieに保存した状態を確認*/ if(getCookie("OPEN")){ /*正常に取得できたならダイアログ表示*/ $("#mado1").ipop(); } }); /*cookie の取得と中身の有無を確認*/ $(function getCookie(keyname) { return ($.cookie(keyname)!="undefined"); }); /*cookie の保存処理*/ $(function setCookie( keyname, val ) { /*値が指定されていたら保存、空文字列なら削除*/ if( state != "" ){ /*cookieに保存*/ $.cookie(keyname, val) } else{ /*cookieのクリア*/ $.cookie(keyname, "", {expires: -1}); } }); }); </script> <style type="text/css"> .ipop { padding: 0; background-color: #fed; width: 300px; height: 200px; border: 1px solid #aaa; /* この3行は必須 */ position: absolute; display: none; z-index: 9999; } .ipop_search { padding: 0; background-color: #fed; width: 300px; height: 400px; border: 1px solid #aaa; /* この3行は必須 */ position: absolute; display: none; z-index: 9999; } .ipop_title { background-color: #fdc; cursor: move; } .ipop_close { cursor: pointer; float: right; } </style> <title>ポップアップウインドウテスト</title> </head> <body> <a href=./test109.php?id=1>テスト0</a><br> <?php if ($_GET["id"] == "1") { echo "テスト1<br>"; } ?> <input type='button' value='検 索' id='open1'> <div class="ipop_search" id="mado1"> <div class="ipop_close">×</div> <div class="ipop_title">検索</div> <?php echo "<form action='./test109.php' method='post'>"; echo"<input type='text' name='keyword' style='width:240px;'><input type='submit' value='検索'>"; echo "<form>"; $keyword = $_POST['keyword']; echo '<div id="kwd">'.$keyword.'</div>'; ?> </div> </body>
(function($) {
$.fn.ipop = function() {
var $this = $(this); var wx, wy; // ウインドウの左上座標 var mx, my; // マウスの座標 // ウインドウの座標を画面中央にする。 wx = $(document).scrollLeft() + ($(window).width() - $(this).outerWidth()) / 2; if (wx < 0) wx = 0; wy = $(document).scrollTop() + ($(window).height() - $(this).outerHeight()) / 2; if (wy < 0) wy = 0; // ポップアップウインドウを表示する。 $this.css('top', wy).css('left', wx).fadeIn(100); // 閉じるボタンを押したとき $this.find('.ipop_close').click(function(){ $this.fadeOut(100);}); // タイトルバーをドラッグしたとき $this.find('.ipop_title').mousedown(function(e) { mx = e.pageX; my = e.pageY; $(document).mousemove(mouseMove).mouseup(mouseUp); return false; }); function mouseMove(e) { wx += e.pageX - mx; wy += e.pageY - my; $this.css('top', wy).css('left', wx); mx = e.pageX; my = e.pageY; return false; } function mouseUp() { $(document).unbind('mousemove', mouseMove).unbind('mouseup', mouseUp); } }
})(jQuery);
ShunsukeIzuiのおかげでエラーが出ていた所を解決しましたが、新たに
また別のエラーが発生しました。
『if(getCookie("OPEN")){』の行で以下のエラーが発生しております。
Uncaught ReferenceError: getCookie is not defined
バージョンに問題があるのかとかcookieの定義の仕方に問題があるのか
調べてみましたが解決策が上手く見つかりません。
大変恐縮ですが、また皆様のお力をお借りしたくご教示頂くようお願い
申し上げます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/06/11 14:25
2015/06/11 23:55
2015/06/11 23:58
退会済みユーザー
2015/06/12 11:41
退会済みユーザー
2015/06/12 11:43
退会済みユーザー
2015/06/12 11:47
2015/06/12 23:34