How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
tag on press enter whereas the other browsers are adding either a
or
tag will be placed and the // text will place inside the p tag // 2) If the user selects the whole code and deletes it and begins to type again // 3) If the user types normally and press enter // NB: Please note me if you find any bug if (browserName == "firefox") { //remove all br tags var brs = txteditor.getElementsByTagName("br"); for (var i = 0; i < brs.length; i++) { brs[i].parentNode.removeChild(brs[i]); } //check whether there is a p tag inside var para = txteditor.getElementsByTagName("p"); if (para.length == 0) { var inner = txteditor.innerHTML.replace(/^s+|s+$/g, ); var str = (inner == "") ? "" : txteditor.innerHTML; var nText = "
" + str + "
"; // in order to prevent a dublicate row clear inside the text editor txteditor.innerHTML = ""; document.execCommand( insertHTML , false, nText); } else { // always make sure that the current row s innerHTML is never empty if (document.getElementById(cRow).innerHTML == "") document.getElementById(cRow).innerHTML = ""; } }. I haven t tested this with other elements, but it would be interesting to see how different elements would behave. A element can be styled with display: block to make it look like a
in Firefox, but didn t find any
or
was inserted either when the content is empty or after pressing space. Anyway, I tried to solve it by MutationObserver API. It didn t work perfectly but I failed to find other solutions that meets my requirement. if (navigator.userAgent.includes( Firefox )) { const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { // when a
inserted if (mutation.addedNodes.length === 1 && mutation.addedNodes[0].tagName === BR ) { // if at the beginning, remove it if (mutation.previousSibling === null) return mutation.addedNodes[0].remove() // or if after a space, remove it and add a space // since it seems Firefox need the
to keep that space if (mutation.previousSibling.nodeValue?.endsWith( )) { mutation.target.insertAdjacentText( beforeend , ) mutation.addedNodes[0].remove() } } }) }) observer.observe(contentEditableDiv, { childList: true }) } Side effects: Must input twice to add a new line, or to add a space sometimes Unable to make the content a single new line The problem is also mentioned as a bug in Firefox issue tracker: https://bugzilla.mozilla.org/show_bug.cgi?id=1615852 Extract that may help:
elements are required when: block elements are empty, for making them non-zero height and to put the first line for good caret position text ends by a collapsible white-space, to make it visible
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding