当前位置: 首页 > news >正文

怎么合作做网站装修公司装饰

怎么合作做网站,装修公司装饰,为了同学都能访问网站如何做,网站开发职业访谈HTML页面之间的数据传递 1.通过window.location.href发送#xff0c;location.search接收2.通过window.location.open()发送 1.很多小伙伴在做页面时#xff0c;有没有想过两个页面之间如何在跳转的同时#xff0c;还能够传递一些数据过去   2.跳转页面时#xff0c;我们… HTML页面之间的数据传递 1.通过window.location.href发送location.search接收2.通过window.location.open()发送 1.很多小伙伴在做页面时有没有想过两个页面之间如何在跳转的同时还能够传递一些数据过去   2.跳转页面时我们首先想到的是利用a标签进行跳转。   3.一般我们通过a标签的方式只能进行页面之间的跳转而无法将想要的数据传递过去。   4.接下来将讲解两个页面之间如何进行数据的传递。 1.通过window.location.href发送location.search接收 1这里我们一般将window.location.href绑定在点击事件上进行跳转它类似于a标签但是可以传递参数。 01.html页面代码如下 !DOCTYPE html html langen headmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestylebutton{width: 300px;height: 300px;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);background-color: aquamarine;}/style /head bodyh1 styletext-align: center;01.html/h1button点击我跳转/button /body scriptlet buttondocument.getElementsByTagName(button)[0]button.onclickfunction(){//路径参数名参数值window.location.href ./02.html?unamezhangsan//2.下面这种方式将数据进行编码可以传递中文不出现乱码推荐// window.location.href encodeURI(./02.html?uname哈哈);} /script /html1这里我们利用location.search来接收数据 02.html页面代码如下 !DOCTYPE html html langenheadmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestylebutton {width: 300px;height: 300px;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);background-color: aquamarine;}/style /headbodyh1 styletext-align: center;02.html/h1button点击我弹出接收信息/button /body scriptvar name location.search;// var name decodeURI(document.URL)//获取到编码的数据并进行解码推荐//获取到的数据其实是 ?unamezhangsan//下面是对数据进行处理namename.slice(name.indexOf()1)console.log(name);var button document.querySelector(button);button.onclick function () {alert(name)} /script/html效果如下 2.通过window.location.open()发送 如果是希望打开一个新页面而不是改变当前的页面那么window.location.href就不适用了此时我们需要借助于window.open()来实现 它是用来打开一个新的浏览器窗口或查找一个已命名的窗口。 window open()用法 01.html页面代码如下 !DOCTYPE html html langen headmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestylebutton{width: 300px;height: 300px;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);background-color: aquamarine;}/style /head bodyh1 styletext-align: center;01.html/h1button点击我跳转/button /body scriptlet buttondocument.getElementsByTagName(button)[0]button.onclickfunction(){//路径参数名参数值 使用encodeURI进行编码可以传中文window.open(encodeURI(./02.html?uname哈哈哈))} /script /html02.html页面代码如下 !DOCTYPE html html langenheadmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestylebutton {width: 300px;height: 300px;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);background-color: aquamarine;}/style /headbodyh1 styletext-align: center;02.html/h1button点击我弹出接收信息/button /body script//对数据进行解码var name decodeURI(document.URL)//获取到的数据其实是 ?uname哈哈哈//下面是对数据进行处理namename.slice(name.indexOf()1)var button document.querySelector(button);button.onclick function () {alert(name)} /script /html效果如下所示 觉得对你有帮助的话点个赞再走吧
http://www.hkea.cn/news/14354723/

相关文章:

  • 北京注册网站做网站和做网页有什么区别
  • 潍坊住房与城市建设部网站网址之家
  • 做网站上的图片如何设定分辨率建设银行鹤岗分行网站
  • 上海出啥大事了今天seo推广的特点
  • 开发网站的流程是学校招办网站怎么做
  • 做网站公司不负责任怎么办建筑信息平台查询
  • 家里面的服务器可以做网站吗wordpress建站方便吗
  • 网站建设技术 翻译wordpress 修改数据库连接
  • 网站怎么做切换中英文网站底部图片
  • 云南手机网站建设zencart 网站老是跳转到原地址
  • 垂直电商网站有哪些产品宣传小视频制作
  • 网站建设 软件有哪些一个网站建设需要花多少钱
  • 南宁网站建公司外文网站做t检验分析
  • 常州商城网站制作公司购物网站页面设计步骤
  • 龙川县建设网站四川平台网站建设方案
  • 上海高端网站建设服中山蓝图科技网站建设
  • 免费网站设计培训班科技大学全国排名
  • 企业做网站需要提交的资料表格wordpress一键分享微博
  • 网站设计公司长沙婚礼视频制作软件
  • 部门网站建设怎么做建筑企业名单和电话
  • 口子网站怎么做张掖建设网站
  • 删除网站内容嵩明县住房和城乡建设局网站
  • 网站编辑工作内容怎么写烟台广告公司南网站建设评价
  • 俄文视频网站开发苏州集团网站设计公司
  • 苏州企业建设网站服务网站建设外包注意事项
  • 网站开发的项目内容网页设计实训3000字
  • 寻找大连网站建设江苏体育建设场地网站
  • 自助建站英文wordpress下载弹窗
  • 用自己电脑配置服务器做网站静态单页网站wordpress
  • 如东建设局网站公司装修开工仪式需要准备什么