I am using code to create a custom context menu. Its working however there is an issue in Firefox. When right clicking on either a Select box/dropdown list or a button it gives me the following error in Firefox:
TypeError: this.target is undefined
[Break On This Error] Filtered chrome url chrome://browser/content/nsContextMenu.js
nsContextMenu.js (line 162)
TypeError: gContextMenu is null
The following code works in Chrome and Internet Explorer but gives an error in Firefox:
$(document).on("contextmenu",function(e){
if($(e.target).prop("tagName")=="A"){
//do something
}
});
Note that this error only happens in Firefox so far with the following tags when right clicking on them.
<select>
<button>
<input type='checkbox'>
Text boxes work fine however.
Edit: Ok it seems even with no code inside "contextmenu" function it still gives the error.
Update: This appears to be a Firebug issue in Firefox as no erros appear using Firefox's Developer tools javascript console.
This issue can be solved by disabling Firebug. It is a firebug related issue and not a Firefox bug in itself.
Try using tag name with DOM object like this e.target.tagName
$(document).on("contextmenu",function(e){
if(e.target.tagName =="A"){
//do something
}
});
Related
Assuming I have following HTML
<div id="box" style="display:none;">Hello World</div>
<button id="showbutton">Show The Box</button>
And following JQuery button handler to show the div
$('#showbutton').click(function() {
console.log('test');
$('#box').show();
});
Notice the console.log statement. If I click the button on a freshly opened IE9 browser, it won't work. It seems the console object is not yet initialized. But if I press F12 to open the developer console, the handler will work.
This behavior doesn't exist on Chrome/Firefox.
Is this an expected behavior of console object on IE? Is there a documentation related to javascript console object support on IE?
JSFiddle for the demo is here: http://jsfiddle.net/6tHB5/.
To reproduce the problem on IE, you have to close your browser first, run the browser again, then click the button straight away without opening developer console (F12)
Yes, this is unfortunately just how IE works. There are a few possible solutions:
You can check beforehand if you want to avoid JS errors.
$('#showbutton').click(function() {
if (console) console.log('test');
$('#box').show();
});
Make your own log function to check automatically.
function log(){
if (console) console.log.apply(console, arguments);
}
You could also mock out the console like this at the top of your page to make life easier:
if (!window.console) window.console = {log: function(){}};
In IE 9 console object is not defined before it opened, so you should check it before log:
$('#showbutton').click(function() {
if (typeof console != 'undefined') console.log('test');
$('#box').show();
});
I have TinyMCE 4.0 in the page and when I select the text and try to paste it via CTRL+V, I get an error message saying that "Clipboard access not possible." This happens in IE8/9. However the same works fine in Chrome. Is there any workaround for this to get this working in IE?
Bounty:
I've tried resetting all IE settings (via Internet Options->Advanced->Reset All...) on two different computers, both running IE9, and one has the problem while the other does not.
Ultimately, I need to be able to paste formatted text (often with bullets or numeric lists and such) into TinyMCE and have it format them correctly. For this, I'm using the paste plugin, which seems to be throwing the error.
It seems to me that you're using an older TinyMCE 4 version, so in my opinion you should first do an upgrade to the latest version (4.0.3).
I've checked the source code of such version and I've found no trace of the Clipboard access not possible error message, which seems instead to be present in an earlier version of the tinymce/plugins/paste/plugin.min.js file, and only for Internet Explorer:
e.ie ? o.on("init", function () {
var e = o.dom;
o.dom.bind(o.getBody(), "paste", function (n) {
var r;
if (n.preventDefault(), a() && e.doc.dataTransfer)
return c(e.doc.dataTransfer.getData("Text")), t;
var i = u();
e.bind(i, "paste", function (e) {
e.stopPropagation(), r = !0
});
var s = o.selection.getRng(),
f = e.doc.body.createTextRange();
if (f.moveToElementText(i.firstChild), f.execCommand("Paste"), d(), !r)
return o.windowManager.alert("Clipboard access not possible."), t;
var p = i.firstChild.innerHTML;
o.selection.setRng(s), l(p)
})
}
Not being able to find an unminified version of this script, I can't say why such code fails, nor can I explain why it works only on one of your's computers.
In Internet Explorer's Tools menu, choose Internet Options.
Click the Security tab.
Click Trusted Sites.
Click the Sites... button.
Type your domain name (for example, widgetdesigns.com) in the first field, then click Add.
Unselect the checkbox that says Require server verification (https:) for all sites in this zone.
Click OK to apply your change.
Back on the Security tab, confirm that Trusted Sites is still selected, then click the Custom Level button.
Scroll down the Security section (near the bottom) and check the Disable box below Allow Programmatic clipboard access. (Checking this box will disable the access alert only for sites in your Trusted Sites list.)
Click OK then OK again to apply your changes.
What about this? Does this work?
I'm encountering quite a weird JavaScript Issue in IE9 (It works fine tough in Chrome, Safari, Firefox).
I have some JS that selects a different Color of an Image when you click on that associated swatch. In IE9, it seems that is completely ignoring this and it is simply doing nothing. But, as soon as I open up the F12 Developer Tools it starts working - Even without reloading the page. Am I mising something here?
jQuery
$('.product-details-description-colors .circle img').click(function() {
if(!$(this).hasClass('oos')) {
url = $(this).parent('label').data('image');
color_value = $(this).parent('label').prev('input');
color_value.prop('checked', true);
$('.circle').find('input').not(color_value).attr('checked', false);
$(this).css('outline', '1px solid black');
$('.product-details-description-colors .circle img').not(this).css('outline', 'none');
$('.product-details-images-showroom img').attr('src', url);
}
});
I assume you haven't posted all your code. One of the most common causes of this is trying to use the console object, specifically console.log. This is only available when the F12 tools are open and if they aren't, it will cause mysterious errors from propagating undefined.
Hence, this is a good idea to put somewhere in your coffeescript app:
# Fix IE logging issues
if not window.console
window.console =
log: ->
Hello I getting not visible IFrame in IE I try print it, but IE return error what focus() method not identified. Why I get it? I remember that some days ago it wored
var iFrame = document.frames["printIfram"]; //document.frames.printIframe;
iFrame.focus();
iFrame.print();
Put a print function inside the Iframe to make it print itself on load:
At the bottom of the page, just use window.print()
You missed the e on the end of printIframe.
If that's just a typo, try iFrame.contentWindow.focus().
i got the same problem in ie8 and i thought it's a bug of ie
i tryed the accepted answer ,it haven't work yet;
nomatter where is the window.print(),it always print the parent page
so ,i give up the iframe,just open a new tab to print
have you got it work?
I can't seem to figure out why the following simple popup will not work in IE9. FF & Chrome popup as expected, but IE does not appear to do anything when the link is clicked. I tried the IE9 debugger, but didn't get any helpful information out of it.
In the head section:
<script type="text/javascript" language="JavaScript">
function JSPopup(linkref) {
window.open(linkref,"Report Definitions","width=600,height=480");
return false;
}
In the body:
<strong>Report Definitions</strong>
Thanks for your help,
Filip
Turns out the problem was the name given to the popup - IE doesn't allow spaces, FF & Chrome do:
window.open(linkref,"Report Definitions","width=600,height=480");
needed to be changed to:
window.open(linkref,"ReportDefinitions","width=600,height=480");
This works across browsers.
Filip
This is part of the security changes made in IE6. Now you can only call "window.open" from within a user-initiated event. For example, your code would work inside an element's onclick event. The "window.open" http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx MSDN page says this:
"This method must use a user-initiated action, such as clicking on a link or tabbing to a link and pressing enter, to open a pop-up window. The Pop-up Blocker feature in Internet Explorer 6 blocks windows that are opened without being initiated by the user."
Example...
function popUpWin(url,wtitle,wprop){
if (!window.open){ return; } // checking if we can't do this basic function
// Kill if(win), since win was a local var this was a usless check
var win = window.open(url,wtitle,wprop);
// next line important in case you open multiple with the same 'wtitle'
// to make sure the window is reused and refocused.
if (win && win.focus){ win.focus(); }
return false;
}