顺义专业建站公司,新电商网站,绍兴网站建设优化,专业网站建设微信官网开发Bom节点 代表浏览器对象模型#xff08;Browser Object Model#xff09;#xff0c;它是浏览器提供的 JavaScript API#xff0c;用于与浏览器窗口和浏览器本身进行交互 获取当前网页的URL#xff1a; const currentURL window.location.href;
console.log(currentURL…Bom节点 代表浏览器对象模型Browser Object Model它是浏览器提供的 JavaScript API用于与浏览器窗口和浏览器本身进行交互 获取当前网页的URL const currentURL window.location.href;
console.log(currentURL); 设置和获取Cookies: // 设置一个名为 username 的 Cookie
document.cookie usernameJohn Doe;
// 获取 Cookie 值
const username document.cookie;
console.log(username);
导航到其他页面 window.location.href 跳转页面的地址; 获取浏览器信息 const web window.navigator.appName;
const web_v window.navigator.appVersion;
console.log(浏览器名称: ${web}, 版本: ${web_v}); id1.style.color red; //属性使用 字符串 包裹
id1.style.fonSize 20px;// 驼峰命名问题
id1.style.padding 2em; 获取表单的获取值 文本框 text 下拉框 select 单选框 radio 多选框 checkbox 隐藏框 hidden 密码框 password form actionpostPspan用户名/spaninput typetext idusername/PPspan性别/spaninput typeradio namesex valueman idboy男input typeradio namesex valuegirl idboy女/P/formscriptlet input_text document.getElementById(username);/script 输出的语句是input_text.value,将文本框的文字输出 boy_text.checked
true
girl_text.checked
false 如上代码 radio的选择框选择男选择框的用checked,不能用value 密码加密 script scrhttps://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5/2.10.0/js/md5.min.js/script//引用mp5加密网站
/head
bodyform ation# methodpostpspan用户名/spaninput typetext idusername nameusername/ppspan密码/span!-- password可以让密码隐蔽 --input typepassword idpassword namepassword/p!-- 绑定事件onlick被点击 --button typesubmit onlickaaa()提交/button/formscriptfunction aaa() {let uname document.getElementById(username);let pwd document.getElementById(password);console.log(uname.value);console.log(pwd.value);// pwd.value *******;pwd.value md5(pwd.value);console.log(pwd.value);}/script
/body 隐藏密码加密 headmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlescript scrhttps://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5/2.10.0/js/md5.min.js/script
/head
body!-- onsubmit绑定一个提交检测的函数true false 将这个结果返回给表单使用onsubmit 接收onsubmit return aaa() --form actionhttp://www.baidu.com methodpost onsubmitreturn aaa()pspan用户名/spaninput typetext idusername nameusername/ppspan密码/spaninput typepassword idinput-password namepassword/pinput typehidden idmd5-password namepasswordbutton typesubmit提交/button/form
scriptfunction aaa() {let name document.getElementById(username);let pwd document.getElementById(input-password);let mp5pwd document.getElementById(md5-password);pwd.value md5(pwd.value);mp5pwd.value md5(pwd.value);//将加密的密码在进行隐藏// 可以校验判断表单内容true就是通过提交false,阻止提交return true;}/script