| 0 | 1 <!DOCTYPE html> | 
|  | 2 <html> | 
|  | 3 	<head> | 
|  | 4 		<meta charset="utf-8"> | 
|  | 5 		<title>iFrame message passing test</title> | 
|  | 6 		<meta name="description" content="iFrame message passing test"> | 
|  | 7 		<script src="jquery.js"></script> | 
|  | 8 		<style> | 
|  | 9 			a { float:right; } | 
|  | 10 		</style> | 
|  | 11 	</head> | 
|  | 12 	<body> | 
|  | 13 | 
|  | 14 		<b>iFrame</b> | 
|  | 15 | 
|  | 16 		<p> | 
|  | 17 			Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | 
|  | 18 		</p> | 
|  | 19 		<p> | 
|  | 20 			But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? | 
|  | 21 		</p> | 
|  | 22 		<p> | 
|  | 23 			On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains. | 
|  | 24 		</p> | 
|  | 25 		<p> | 
|  | 26 			Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | 
|  | 27 		</p> | 
|  | 28 		<p> | 
|  | 29 			But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? | 
|  | 30 		</p> | 
|  | 31 		<p> | 
|  | 32 			On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains. | 
|  | 33 		</p> | 
|  | 34 		<p> | 
|  | 35 			Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | 
|  | 36 		</p> | 
|  | 37 		<p> | 
|  | 38 			But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? | 
|  | 39 		</p> | 
|  | 40 		<p> | 
|  | 41 			On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains. | 
|  | 42 		</p> | 
|  | 43 		<p> | 
|  | 44 			Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | 
|  | 45 		</p> | 
|  | 46 		<p> | 
|  | 47 			But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? | 
|  | 48 		</p> | 
|  | 49 		<p> | 
|  | 50 			On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains. | 
|  | 51 		</p> | 
|  | 52 | 
|  | 53 | 
|  | 54 		<script type="text/javascript" src="../../js/iframeResizer.contentWindow.min.js"></script> | 
|  | 55 		<script type="text/javascript"> | 
|  | 56 | 
|  | 57 			(function() { | 
|  | 58 | 
|  | 59 				var | 
|  | 60 					msgID	= '[iFrameSizerTest]',  //Must match host page msg ID | 
|  | 61 					firstRun = true, | 
|  | 62 					logging = true, | 
|  | 63 					msgIdLen= msgID.length; | 
|  | 64 | 
|  | 65 				try{ | 
|  | 66 | 
|  | 67 					function addEventListener(e,func){ | 
|  | 68 						if (window.addEventListener){ | 
|  | 69 							window.addEventListener(e,func, false); | 
|  | 70 						} else if (window.attachEvent){ | 
|  | 71 							window.attachEvent('on'+e,func); | 
|  | 72 						} | 
|  | 73 					} | 
|  | 74 | 
|  | 75 					function log(msg){ | 
|  | 76 						if (logging && window.console){ | 
|  | 77 							console.log(msg); | 
|  | 78 						} | 
|  | 79 					} | 
|  | 80 | 
|  | 81 					function warn(msg){ | 
|  | 82 						if (window.console){ | 
|  | 83 							console.warn(msg); | 
|  | 84 						} | 
|  | 85 					} | 
|  | 86 | 
|  | 87 					function receiver(event) { | 
|  | 88 | 
|  | 89 						function init(){ | 
|  | 90 | 
|  | 91 							function changeContent(){ | 
|  | 92 								$('p').eq(0).remove(); | 
|  | 93 							} | 
|  | 94 | 
|  | 95 							function callMethod(methodName,val1,val2){ | 
|  | 96 								if ('parentIFrame' in window) | 
|  | 97 										window.parentIFrame[methodName](val1,val2); | 
|  | 98 									else | 
|  | 99 										warn('window.parentIFrame methods not enabled.') | 
|  | 100 							} | 
|  | 101 | 
|  | 102 							var | 
|  | 103 								data = event.data.substr(msgIdLen).split(':'), | 
|  | 104 								test = data[1]; | 
|  | 105 | 
|  | 106 							console.info(test); | 
|  | 107 | 
|  | 108 							switch (test){ | 
|  | 109 								case 'changeContent': | 
|  | 110 									setInterval(function(){changeContent();},2); | 
|  | 111 									break; | 
|  | 112 								case 'close': | 
|  | 113 									callMethod('close'); | 
|  | 114 									break; | 
|  | 115 								case 'pageChange': | 
|  | 116 									location.href = '../../example/frame.hover.html'; | 
|  | 117 									break; | 
|  | 118 								case 'nested': | 
|  | 119 									location.href = 'frame.nested.html'; | 
|  | 120 									break; | 
|  | 121 								case 'size': | 
|  | 122 									changeContent(); | 
|  | 123 									callMethod('size'); | 
|  | 124 									break; | 
|  | 125 								case 'size100': | 
|  | 126 									callMethod('size',100); | 
|  | 127 									break; | 
|  | 128 								case 'size200300': | 
|  | 129 									callMethod('size',200,300); | 
|  | 130 									break; | 
|  | 131 								case 'jsTrigger': | 
|  | 132 									changeContent(); | 
|  | 133 									callMethod('trigger'); | 
|  | 134 									break; | 
|  | 135 								case 'chkHeight': | 
|  | 136 									callMethod('sendMessage',document.body.offsetHeight); | 
|  | 137 									break; | 
|  | 138 								case 'chkBackground': | 
|  | 139 									callMethod('sendMessage',document.body.style.background); | 
|  | 140 									break; | 
|  | 141 								case 'chkSendMsg': | 
|  | 142 									callMethod('sendMessage','message: test'); | 
|  | 143 									break; | 
|  | 144 								case 'chkGetId': | 
|  | 145 									if ('parentIFrame' in window) | 
|  | 146 										callMethod('sendMessage',window.parentIFrame.getId()); | 
|  | 147 									break; | 
|  | 148 								case 'setHeightCalculationMethod': | 
|  | 149 									if ('parentIFrame' in window){ | 
|  | 150 										parentIFrame.setHeightCalculationMethod('max'); | 
|  | 151 										callMethod('size'); | 
|  | 152 									} | 
|  | 153 									break; | 
|  | 154 								case 'width': | 
|  | 155 									$('p').width(3000); | 
|  | 156 									break; | 
|  | 157 								case 'image': | 
|  | 158 									$('p').html('<img src="djb.jpg">'); | 
|  | 159 									break; | 
|  | 160 							} | 
|  | 161 | 
|  | 162 						} | 
|  | 163 | 
|  | 164 | 
|  | 165 						if (msgID === event.data.substr(0,msgIdLen) ){ //Check msg ID | 
|  | 166 							init(); | 
|  | 167 						} | 
|  | 168 					} | 
|  | 169 					addEventListener('message', receiver); | 
|  | 170 				} | 
|  | 171 				catch(e){ | 
|  | 172 					warn(e); | 
|  | 173 				} | 
|  | 174 | 
|  | 175 			})(); | 
|  | 176 		</script> | 
|  | 177 	</body> | 
|  | 178 </html> |