window.getSelection() doesn't work properly on Firefox - javascript

I am facing a compatibility issue with firefox and window.getSelection() to get the selected textarea id from a list of textareas.
I am working on something like adding specific tags to a piece of text: click on a textarea then click on insert tags button.
I am using window.getSelection().focusNode.firstElementChild.id to get the active textarea and then update its content. It works perfectly for Chrome, however I got this error on Firefox: window.getSelection().focusNode is null
Can anyone help me to figure out what might be causing this or if there is a work around?
Thanks.

Related

Chrome + JSFiddle OPTION element bug

This really has me scratching my head.
The OPTION text is cleared using this code in a Snippet:
document.querySelector('option').textContent = '';
<select>
<option>Ipso</option>
</select>
It also works in a CodePen, plus it works on my website.
However, in JSFiddle it fails – but only in Chrome.
If I set textContent to anything prior to clearing it, it then works.
This issue doesn't seem to occur with any other type of element.
If I use innerText or innerHTML instead of textContent, I get the same behavior – but again, only in Chrome. jQuery's text() method also gives the same behavior.
Is this a Chrome bug or a JSFiddle bug?
I don't know the reason for the bug, but try setting the load type (click the cog in the top right corner of the JavaScript frame) and select no wrap - in <body>.
It works on the Chrome browser on my phone (whilst your fiddle didn't), and could possibly explain what's gone wrong.

tinymce execCommand behaving weird in Chrome

I got a custom button that when I click it with the editor opened, it does the following:
tinymce.execCommand(command, false, action)
command is for example "mceToogleFormat", and action can be for example "bold" to toggle a text node from normal to bold.
Weird thing is, if I press that button, it doesn't apply the bold format, and the caret goes to the beginning of the text.
Now if I run the same line of execCommand in the console, it runs perfectly... i'm really intrigued on why this isn't running during runtime with the custom button, but it's working when i write it in the console.
I upgraded the tinymce to the last version 4.1.7.
I was using 4.0.26 and the code works perfectly with it.
After debugging tinymce code and my code, i saw that the range is somehow lost when i click on my custom button.
Is there any way to solve this? Is it a focus problem? I thought about that, but... shouldn't I be losing the focus when i click in the console too? and nevertheless, that works? I can't understand this anymore, I really appreciate any help given.
(Firefox and IE 11 works as intended, only Chrome is having issues)

CSS HTML: Text Wraps in Chome: Works fine in Firefox and IE

I have html and css as posted in http://jsfiddle.net/SLs47/ . When I open it in Chrome the title text get wraped (and misaligns) while zoom is increased. However it works fine in Firefox. Please see the following images.
What need to be altered inorder to make it working?
Chrome
Although i couldn't reproduce the error, i think changing #titleinfo 's display property to inline-block from inline should prevent it from wrapping.

Javascript works fine in firefox but not in ie and chrome

http://www.measureraajje.com/
The webpage works fine in firefox and opera,
but it doesn't work at all in internet explorer, google chrome and safari.
HOW IT SHOULD WORK:
The user should select an atoll first... then the adjacent combobox should display a list of islands.
After selecting 2 islands. the user will have to press add route... then the route will be added and the result will be displayed in the table below.
Use a single script tag at the end of the body tag and put in every js code which are using html elements of the page. Html elements must be present before excecuting javascript code.

Javascript slider not showing in IE9

We have an automatic slider on this website, http://www.realcapfinancial.com and it has been working on all browsers. IE9 doesnt seem to work. It comes up with and error, no object line 298... character 2 etc. I forget what it says but I can't check it again since I'm at work using a mac.
Any help is perfect, thank you
The element with id calcclick is only added after the Resources tab is click. However, this element is already adressed (on line 298) on page load.

Categories