惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - JoyBin

使用CSS为图片添加更多趣味的5种方法. IT工作者要保护自己的头发啊.. document.execCommand()用法说明 用三层架构与设计模式思想部署企业级数据库业务系统开发(转) C#代码与javaScript函数的相互调用 IE6 png 透明 (三种解决方法)(转) - JoyBin 程序人生就像一场恶梦。 常用正则表达式 [转载]Meta标签详解 三级联动-完美版 - JoyBin - 博客园 asp.net(C#)服务器绝对路径转换成URL相对路径[修改] (转) flash的菜单与asp.net进行交互(转) 把生成的缩略图存到数据库中 母版页判断登陆 及 母版页与内容页的执行顺序 常用.net代码 常用JS代码 SQLServer存储过程分页 WMPLib.WindowsMediaPlayer 的用法 网页播放器 PlayState 的用法
添加html内容(insertAdjacentHTML和insertAdjacentText)
JoyBin · 2008-04-18 · via 博客园 - JoyBin

添加html内容(insertAdjacentHTML和insertAdjacentText)
     dhtml提供了两个方法来进行添加,insertAdjacentHTML和insertAdjacentText
insertAdjacentHTML方法:在指定的地方插入html标签语句。
     原型:insertAdjacentHTML(swhere,stext)
     参数:
     swhere:指定插入html标签语句的地方,有四种值可以用:
               1.beforeBegin:插入到标签开始前
               2.afterBegin:插入到标签开始标记后
               3.beforeEnd:插入到标签结束标记前
               4.afterEnd:插入到标签结束标记后
               stext:要插入的内容
       例:var sHTML="<input type=button onclick=" +      "go2()" + " value='Click Me'><BR>"
       var sScript='<SCRIPT DEFER>'
       sScript = sScript +      'function go2(){ alert("Hello from inserted script.") }'
       sScript = sScript + '</script' + '>';
       ScriptDiv.insertAdjacentHTML("afterBegin",sHTML + sScript);
       在html正文中加入一行:
     <DIV ID="ScriptDiv"></Div>
      最终变成:
     <DIV ID="ScriptDiv">
        <input type=button onclick=go2() value='Click Me'><BR>
        <SCRIPT DEFER>
          function go2(){alert("Hello from inserted sctipt.")}'
        </script>
      </DIV>
      insertAdjacentText方法与insertAdjacentHTML方法类似,只不过只能插入纯文本,参数相同