innerhtml

js中innerText,innerHTML的用法

只谈情不闲聊 提交于 2020-02-22 10:58:21
innerText,outerText,innerHTML,outerHTML 这次我们要使用另一些对象属性对来实现动态改变文本,它们就是:innerText,outerText,innerHTML,outerHTML,千万要注意它们的大小写,因为错一点您就得不到预期的效果了。这是全新的方法,当您掌握它以后将可随心所欲的设计动态内容了,不可错过哦! 例12 动态改变文本和Html <html> <head> <title>DHtml举例12</title> <style><!-- body {font-family:"宋体";color="blue";font-size="9pt"} --> </style> <script language="JavaScript"> function changeText() { DT.innerText="我很好!"; }//function function changeHtml() { DH.innerHTML="<i><u>我姓肖!</u></i>"; }//function function back() { DT.innerText="您好吗?"; DH.innerHTML="您姓什么?"; } </script> </head> <body> <p><font color="gray">请点击下边的文字……</font> <ul>

JavaScript中的innerHTML

半世苍凉 提交于 2020-02-16 20:01:31
JavaScript中的innerHTML innerHTML在JS是双向功能:获取对象的内容 或 向对象插入内容 <div id="demo">内嵌内容</div> 我们可以通过 document.getElementById('demo').innerHTML 来获取id为demo的对象的内嵌内容 也可以通过 document.getElementById('demo').innerHTML='被插入的内容' 对id为demo的对象插入内容 来源: https://www.cnblogs.com/leerep/p/12317978.html

执行innerHTML中的javascript

依然范特西╮ 提交于 2020-02-14 14:34:15
function execInnerScript(innerhtml) { var temp = innerhtml.replace( / \n | \r / g, "" ); var regex =/< script. +?< \ / script >/ gi; var arr = temp.match(regex); if (arr) { for ( var iiiiiiiiii_iii = 0 ;iiiiiiiiii_iii < arr.length;iiiiiiiiii_iii ++ ) { var temp1 = arr[iiiiiiiiii_iii]; var reg = new RegExp( " ^<script(.+?)>(.+)<\/script>$ " , " gi " ); reg.test(temp1); eval(RegExp.$ 2 ); } } } 在将代码用innerHTML方式插入到网页的时候,里面的javascript不会被执行,通过调用上面的方法可以执行. 需要注意的是如果代码内定义了全局函数必须按下面的格式申明,否则外部调用的时候会出错. window.a = function () { // 函数代码 } 来源: https://www.cnblogs.com/liaowei/archive/2007/08/20/863006.html

how to scrape web page data without losing tags

限于喜欢 提交于 2020-01-25 12:21:59
问题 I am trying to scrape web data using php and dom xpath. When I store the $node->nodeValue into my database or even if i try to echo it, all the tags like <p> and <br> are missing. So I am getting all the paras concatenated. How to solve this problem 回答1: If you have a node, and you need all its contents as they are, you can use this function: function innerHTML(DOMNode $node) { $doc = new DOMDocument(); foreach ($node->childNodes as $child) { $doc->appendChild($doc->importNode($child, true));

how to scrape web page data without losing tags

那年仲夏 提交于 2020-01-25 12:18:26
问题 I am trying to scrape web data using php and dom xpath. When I store the $node->nodeValue into my database or even if i try to echo it, all the tags like <p> and <br> are missing. So I am getting all the paras concatenated. How to solve this problem 回答1: If you have a node, and you need all its contents as they are, you can use this function: function innerHTML(DOMNode $node) { $doc = new DOMDocument(); foreach ($node->childNodes as $child) { $doc->appendChild($doc->importNode($child, true));

innerHTML not rendering after replace

£可爱£侵袭症+ 提交于 2020-01-25 01:33:26
问题 I am trying to get certain words to highlight in a page. To accomplish this, I want to find all text nodes and replace only the specific word with a span that will highlight it. The code appears to search and find the words in the text nodes properly, but the replace is not working. I get this: <span style="background-color: #FBC300;">foo</span> And I want to get this: foo (with a highlighted background) function toRegExp(text) { return new RegExp(text, 'g'); } function toSpan(text) { return

Add input fields to div container (javascript)

时光毁灭记忆、已成空白 提交于 2020-01-22 16:55:45
问题 I want to add some html data to the end of a div container. Currently, I do it with using innerHtml: <script language="javascript"> var addid = 0; function addInput(id){ var docstyle = document.getElementById('addlist').style.display; if(docstyle == 'none') document.getElementById('addlist').style.display = ''; addid++; var text = "<div id='additem_"+addid+"'><input type='text' size='100' value='' class='buckinput' name='items[]' style='padding:5px;' /> <a href='javascript:void(0);' onclick=

Add input fields to div container (javascript)

╄→尐↘猪︶ㄣ 提交于 2020-01-22 16:55:22
问题 I want to add some html data to the end of a div container. Currently, I do it with using innerHtml: <script language="javascript"> var addid = 0; function addInput(id){ var docstyle = document.getElementById('addlist').style.display; if(docstyle == 'none') document.getElementById('addlist').style.display = ''; addid++; var text = "<div id='additem_"+addid+"'><input type='text' size='100' value='' class='buckinput' name='items[]' style='padding:5px;' /> <a href='javascript:void(0);' onclick=

get specific table into excel using VBA

十年热恋 提交于 2020-01-14 03:45:06
问题 I am looking for a way to get a table into excel using VBA. Using a web query is not suitable for specific reasons. So far i have got this Set ie = CreateObject("InternetExplorer.Application") ie.Navigate "http://bmreports.com/servlet/com.logica.neta.bwp_PanBMUTop" ie.Visible = True While ie.Busy DoEvents Wend ie.document.getelementbyid("param5").Value = "2014-04-12" ie.document.getelementbyid("param6").Value = "8" ie.document.getelementbyid("go_button").Click The web page that opens has a

Django, Javascript: Form injected into DOM via javascript innerHtml crashes google chrome tab on submit. Works in IE

僤鯓⒐⒋嵵緔 提交于 2020-01-13 16:23:29
问题 I have written a bookmarklet that receives a Django form and inserts it into the Dom via the innerHtml of a new div element created via javascript and appended to the body of an existing html document. The first submit is an ajax request (works fine), if the form is rejected by Django due to an unknown user, the submit function is unbound from ajax and resubmitted without ajax to a pop-up window to authenticate the user without CORS. The process works flawlessly in IE but crashes the chrome