javascript onclick is not working - javascript

I have an onclick event that works in IE and FireFox, but not in Chrome. Request your inputs on fixing this.
onclick="; var extras=actNoExtras();actHandleReturnValue(actOpenDialogEx('/SiteScope/UI/SelectTableColumns.do?tableId=rfw_monitor_report_monitor_table0_29_0'+extras, 'dialogHeight:400px;dialogWidth:450px;scroll:no;status:no;resizable:no;help:no;dialogtop=184.0;dialogleft=287.0', 'height=400,width=450,top=184.0,left=287.0,scrollbars=no,status=no,resizable=no,modal=yes','no','button.arrange.columns.table', 'true','act'), '');"

I doubt this is it, but could it be due to the extra ';' at the beginning of the code? Also what do you mean by not working. Does the dialog box not open?
In Chrome, you can press F12 and click on the Sources tab to debug your code. If there is an error, you will find an X symbol inside a red circle, along with a text regarding the error.

Related

Open HTML file input with Javascript click not working in Firefox

I have a simple HTML file input that I can open with Javascript in Chrome but not in Firefox.
<input type="file" id="fileImportInput" style="display:none">
document.getElementById('fileImportInput').click(); // this works in Chrome but not Firefox
I'm not sure why this won't work in Firefox. I get no console error, etc. In Chrome the file browser opens and I can select my file no problem. Any ideas?
Thanks.
Edit: just to note that if I remove the display:none style from the input it makes no difference.
I actually got it working. Firefox has a default setting enabled to block pop ups. Just go to Options and check it off. Strange that it includes file dialogs in it's block list.
https://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting#w_is-the-pop-up-blocker-on-and-enabled-for-this-sitehttps://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting#w_is-the-pop-up-blocker-on-and-enabled-for-this-site

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)

javascript line by line debugger

This might sound crazy but is there a debugger out there which automatically breaks on the first line of executed code ?
Sample : suppose I have debug mode on and I click on a button. Now the intelligent debugger should automatically set the breakpoint on the first line inside the .click({}) function.
This way it is very easy to see the starting point and very easy to backtrack.
There must surely be something.
Thanks
Most debuggers in the browser allow you to insert the keyword
debugger;
into your code which will cause a break to occur at that point in the execution.
Chrome with CTRL+SHIFT+J. ;) You can put breakpoints there. I think it also works under FF. Also new versions of IE have JavaScript debuggers (don't remember the shortcut though).
F12 in most browser opens the debugger.
Chrome, Safari, IE have this by default, and for FF there is the Firebug add on.
Also you can debug from visual studio, select debug from the menu --> Attach to process and then select the interter explorer process. But You should enable the script debuging in Internet Explorer first.

how to check javascript syntax error

Firebug looks not capable to check js syntax error...
Is there any good way to do that?
Currently I just wrote a js but the firebug didn't show any error but the functionality is totally broken.
Firebug does do it. Make sure that you have JavaScript Console enabled, you can do so by clicking the Console dropdown and from their select Enabled. You need to press F12 key to open firebug and once you refresh the page, you will see any errors you have in your script in the firebug js console.
If you are using Firefox, you can also press Contr+Shift+J to open firefox's error dialog.
are you sure Firebug is turned on? If it's on, the little bug in the lower right is colored brown. if it's not on, the bug is gray.
also, I find that Web Inspector in Safari/Chrome is better.

Categories