innerhtml

How do I find the string index of a tag (an element) without counting expanded entities?

时间秒杀一切 提交于 2019-12-24 13:42:17
问题 I've got a large piece of text which I want to be able to select, storing the selected part by its startindex and endindex . (For example, selecting or in word would give me startindex 1 and endindex 2 .) This all works properly, but I've got a problem with HTML entities such as & (the ampersand). I've created a little case in which the issue consists. You can see in the fiddle below that the startIndex inflates if you select anything beyond the & , because it doesn't count the & as a single

build dynamic table with innerHTML

孤人 提交于 2019-12-24 01:58:13
问题 I'm trying to build a dynamic table in javascript with innerHTML. When the web app runs, it only prints the console.log, but doesn't build a table. I tried two ways: First: success: function (data, status, jqXHR) { $.each(data, function (index, dati) { console.log(dati) var html = "<table width=\'450\' bgcolor=\'white\' border=\'2\' bordercolor=\'black\' cellpadding=\'10\' cellspacing=\'1\'>\n" + " <tr style=min-width:850px>\n" + " <td>dati.codiceCOmmessa </td>\n" + " <td>dati.commessaMainSub

Problem with Application.DoEvents() while waiting for WebBrowser to finish loading

柔情痞子 提交于 2019-12-24 01:24:33
问题 I'm trying to load WebBrowser content and after that I want to add some text and scroll to the bottom. Here's example of my code: webBrowser1.Url = new System.Uri("file:///" + filePath); webBrowser1.Document.Body.InnerHtml += text; webBrowser1.Document.Body.ScrollTop = webBrowser1.Document.Body.ScrollRectangle.Height; When I run it, there's an unhandled exception "Object reference not set to an instance of an object". Or when I comment line that does the scrolling, then text is added to

Why does changing the innerHTML, of my box, make my button stop working in Greasemonkey?

北战南征 提交于 2019-12-23 22:12:36
问题 So, I wrote a script that loads images one at a time in a new tab... Got a stop button to work thanks to Brock over HERE... Then I broke it adding in the counter that I had written in while waiting for an answer to that question. I can't see any reason that should have broke it... help please? My Script: var box = document.createElement ('div'); box.id = 'mySelectBox'; GM_addStyle ( ' #mySelectBox { ' + ' background: white; ' + ' border: 2px solid red; ' + ' padding: 4px; ' + //' position:

Adding a ASP Control to page from Code Behind within InnerHTML

故事扮演 提交于 2019-12-23 12:56:13
问题 I'm trying to add a button to the webpage, from the code behind. I have a single empty div on my main page that visible on and off, when needed. However the content I wish to create dynamically as the div content can change dependent on conditions. I have realised that within my ASP Control I use a / (backslash) which cancels out my HTML. The problem I now have is understanding how I can get around this with code, is there a way to add ASP Controls to the web page? I am open to suggestions

Adding a ASP Control to page from Code Behind within InnerHTML

徘徊边缘 提交于 2019-12-23 12:55:01
问题 I'm trying to add a button to the webpage, from the code behind. I have a single empty div on my main page that visible on and off, when needed. However the content I wish to create dynamically as the div content can change dependent on conditions. I have realised that within my ASP Control I use a / (backslash) which cancels out my HTML. The problem I now have is understanding how I can get around this with code, is there a way to add ASP Controls to the web page? I am open to suggestions

JQuery changing content of table cell

南笙酒味 提交于 2019-12-23 09:51:44
问题 OK, this is an embarrassingly simple question. Why doesn't the following jQuery example work? Obviously it is supposed to change the 'a' in the table to 'hello'. HTML code: <table id='table1'> <tr> <td>a</td> <td>b</td> </tr> </table>​ JavaScript (JQuery) code: $("#table1 td:contains('a')").innerHTML="hello"; 回答1: use the html function like this $("#table1 td:contains('a')").html("hallo"); if you want use innerHTML (is a DOM method, not a Jquery Method), you have to select the DOMElement

.innerHTML <br> breaking

偶尔善良 提交于 2019-12-23 09:50:06
问题 Why is this breaking? I've not used .innerHTML correctly before and don't know why this would be wrong. function asdf() { document.getElementById("qwerty").innerHTML="A<br> B<br> C<br> D<br>"; } 回答1: You have to escape new-lines in JavaScript string-literals: function asdf() { document.getElementById("qwerty").innerHTML="A<br>\ B<br>\ C<br>\ D<br>"; } Though you could, potentially more-easily, simply insert newlines in the string itself: function asdf() { document.getElementById("qwerty")

How does jQuery treat comment elements?

送分小仙女□ 提交于 2019-12-23 07:48:42
问题 I always thought that jQuery operates only on DOM elements , that is those nodes that have nodeType == 1 . However I'm shocked that while creating HTML $("<p> </p><!-- comment -->") results in: [p, Comment { data=" comment ", length=21, nodeName="#comment", more...}] (Firebug formatting) I accepted some HTML by AJAX and a DOM Comment was created this way and passed somewhere to a function that is applicable only to elements: defaultView.getComputedStyle( elem, null ) Is there some clean way

How does jQuery treat comment elements?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 07:48:01
问题 I always thought that jQuery operates only on DOM elements , that is those nodes that have nodeType == 1 . However I'm shocked that while creating HTML $("<p> </p><!-- comment -->") results in: [p, Comment { data=" comment ", length=21, nodeName="#comment", more...}] (Firebug formatting) I accepted some HTML by AJAX and a DOM Comment was created this way and passed somewhere to a function that is applicable only to elements: defaultView.getComputedStyle( elem, null ) Is there some clean way