一、正则验证用户名
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<input type="text" pattern="[A-Za-z0-9]+" required title="用户名只能包含字母和数字">
<input type="submit" value="提交">
二、跨域postmessage
##----------------------------class03----------------------------------------------------
<meta name="viewport" content="width=device-width, initial-scale=1.0">
window.addEventListener('message', (event) => {
if (event.origin === 'http://www.class2.cn') {
const cookieData = event.data;
console.log('Receive message from parent:', cookieData);
window.parent.postMessage('child message', '*');
$pets = $_POST['pet-select'];
##----------------------------class04----------------------------------------------------
<meta name="viewport" content="width=device-width, initial-scale=1.0">
console.log(document.cookie);
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<iframe id="myIframe" src="http://www.test1.com/" frameborder="0">iframe>
window.onload = function() {
document.cookie = 'sessionid=class2'
const cookieData = document.cookie
window.frames[0].postMessage(cookieData, 'http://www.test1.com/');
window.addEventListener('message', (event) => {
if(event.origin === 'http://www.test1.com')
console.log('Received message from child:', event.data);