码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 正则验证用户名和跨域postmessage


    正则验证用户名 

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Documenttitle>
    7. head>
    8. <body>
    9. <form>
    10. <input type="text" pattern="[A-Za-z0-9]+" required title="用户名只能包含字母和数字">
    11. <input type="submit" value="提交">
    12. form>
    13. body>
    14. html>

    跨域postmessage 

    1. ##----------------------------class03----------------------------------------------------
    2. #index.html
    3. html>
    4. <html lang="en">
    5. <head>
    6. <meta charset="UTF-8">
    7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    8. <title>2023title>
    9. head>
    10. <div>
    11. <h1>www.test1.comh1>
    12. div>
    13. body>
    14. <script>
    15. window.addEventListener('message', (event) => {
    16. if (event.origin === 'http://www.class2.cn') {
    17. const cookieData = event.data;
    18. //处理cookieData
    19. console.log('Receive message from parent:', cookieData);
    20. window.parent.postMessage('child message', '*');
    21. }
    22. })
    23. script>
    24. html>
    25. #web.php
    26. $pets = $_POST['pet-select'];
    27. echo $pets;?>
    28. ##----------------------------class04----------------------------------------------------
    29. #child.html
    30. html>
    31. <html lang="en">
    32. <head>
    33. <meta charset="UTF-8">
    34. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    35. <title>Childtitle>
    36. head>
    37. <body>
    38. <h1>child-htmlh1>
    39. body>
    40. <script>
    41. console.log(document.cookie);
    42. alert(1);
    43. script>
    44. html>
    45. #index.html
    46. html>
    47. <html lang="en">
    48. <head>
    49. <meta charset="UTF-8">
    50. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    51. <title>iframetitle>
    52. head>
    53. <body>
    54. <iframe id="myIframe" src="http://www.test1.com/" frameborder="0">iframe>
    55. body>
    56. <script>
    57. window.onload = function() {
    58. document.cookie = 'sessionid=class2'
    59. const cookieData = document.cookie
    60. window.frames[0].postMessage(cookieData, 'http://www.test1.com/');
    61. }
    62. //添加一个监听事件处理子页面的返回消息
    63. window.addEventListener('message', (event) => {
    64. if(event.origin === 'http://www.test1.com')
    65. console.log('Received message from child:', event.data);
    66. })
    67. script>
    68. html>

  • 相关阅读:
    Redis3.2.12版本服务器迁移
    【C++】字体文件解析(FreeType)
    传输层 知识点总结
    Docker从初学到进阶二(使用Docker命令,自定义镜像,部署微服务集群,配置自己的镜像仓库)
    【Python百日进阶-数据分析】Day121 - Plotly Figure参数: 散点图(三)marker 标记
    云原生下的CI/CD:安装Argo CD
    go协程的栈
    Spring 拦截器实现请求拦截与参数处理【拦截器(Interceptor)和过滤器(Filter)的区别】
    计算机专业毕设课设选题攻略
    在一台笔记本电脑上试用Ubuntu22.04
  • 原文地址:https://blog.csdn.net/weixin_64051859/article/details/133491783
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号