Tinymce won't initialize on Safari - javascript

I have a tinymce editor in my application and everything works fine.
However, I discovered a bug on Safari.
Here's what happens:
I open the page once and everything works fin. I go to another page and then go back to the previous one. Now the tinymce isn't initialized. Instead, I see just a textarea, and these errors in console:
TypeError: 'undefined' is not an object (evaluating 'f.document.selection')
TypeError: 'undefined' is not an object (evaluating 'j.createRange')
which happen in the tiny_mce.js file.
I found another user which had this problem:
http://lists.apple.com/archives/web-dev/2005/Jun/msg00146.html
But there isn't a solution provided. I'm stuck with this, does anyone know what the problem is?

Based on the error you're getting the tinymce lib isn't loading the moment you're calling the init fn. I highly speculate that your browser is loading the page from the cache (bfCache) which stops the event onLoad from running, in which you're script might be dependent on running that event first.
btw, I am working on a web application that operates heavily on tinymce v4 and it works very well in all browsers (Desktop and mobiles) so the bug your facing might be either a caching problem or a reordering the fns your calling. I would recommend you provide a reduced test case on Fiddle to debug that.

Related

jQuery unassign itself after loading

We have a CS-Cart store that we recently moved the directories on. After the move, we have found that the Javascript on the home page is not working correctly. A number of $(document).ready() events aren't working correctly and are throwing a TypeError: $ is not a function error.
After stepping through the concatenated file, we have narrowed the problem down. The file is processed correctly but after the first $(document).ready() event is called, jQuery seems to unassign itself. IE both the jQuery and $ variables are unset.
We have access to a wayback machine copy of the site and that seems to work properly. If we copy the old javascript file across though, we get the same error. This fact seems to suggest that it is some other mechanism that is causing the problem.
Is there a known mechanism that CS-Cart or jQuery will unassign the jQuery variables?
So it turns out that the MailChimp embed code was old and the jQuery noConflict method was causing the issues. Once we turned the embed code off, everything worked as expected.

Sporadically get error only in iFrame: Main.js Interpreted as amd module format, but called System.register

I'm seeing the error below in console only when loading in iframe when loading compiled ES6 Javascript classes using SystemJS v 0.19.41.
system.src.js:3054 Uncaught Error: Module https://d1jbmqjs327xbn.cloudfront.net/_ra/spaces-developer.pxand/assets/js/framework/builder/builder-client.js interpreted as amd module format, but called System.register.
at a. (system.src.js:3054)
at a. (system.src.js:3773)
at a.reduceRegister_ (system.src.js:4268)
at HTMLScriptElement.m (system.src.js:2851)
This seems to be the same issue as the one that was closed a couple years ago, but for this case it only happens in an iframe.
https://github.com/systemjs/systemjs/issues/970
It happens consistently in Safari, but sporadically in Chrome. The issue only started last week with no code change so I'm at a lost on what could have gone wrong. When this error occurs, it simply stop execute the Javascript which is very problematic.
Anyone has any idea on what could be the root cause of this issue?
Just in case this helps anyone. I found that the issue was with jQuery UI as it's using AMD by default. I had to revert back to an older version to fix this issue. The only explanation I have for the sporadic behavior in Chrome is that Chrome doesn't consistently execute scripts at the same rate unlike Safari. However, this still doesn't explain why I started seeing the issue all the sudden without any change.
So if this ever happens to you, look for a library that loads dependencies using AMD by default and either load them using import instead or if you don't have a choice, try rearrange the order of import and move the one that's causing the issue up. For my case, that's not possible and that's why I had to use an older version of jQuery UI.
As for why it only happens when it's in an iframe. Well, it remains a mystery. I can only think that it's because how content in iframe is loaded by browser. I would love to hear an opinion from an expert on this.

Chrome insists on keeping stale/old javascript code and won't reload the recent version

I'm doing some very simple web dev and using chrome's debugger. The included javascript never seems to update when I modify the source. I can delete the contents of the whole file and it still loads stale code (unless I restart chrome). If I remove permissions on the file, it notices and won't load the page but when replacing permissions the old code is back. This happens both when fetching via http and the local file directly. No amount of spamming reload or ctrl-F5 works. I've tried clearing and manually deleting the cache and even setting the don't cache option in the developer options. I don't think chrome's in local modifications mode but I can never tell (this "feature" is amazingly buggy if not sometimes quite desirable). I don't have this issue in firefox but specifically want to test chrome at the moment.
Has anyone seen this before? What are the common causes? What can I do to prevent this happening?
I'm running fedora 18 with google-chrome 31.0.1650.39-1 - and after noting a newer version - 32.0.1700.19-1. Both have the same issue.
I think ctl-shift-r does a "hard reload," ignoring any cache.
I normally get this problem with Dreamweaver, the new code refreshes fine in the dreamweaver window but when I wanna test on chrome it loads the old code. It generally just takes a couple refreshes for the code to catch up - I assumed the problem was because I was running the files off an appache server which could be causing the delay however it's still local

Problem running a jQuery application?

I'm developing a jQuery mobile application. The application is developed in JavaScript, jQuery, and HTML. When I debug the application in browser using Firebug (in Firefox) it's working fine, but it doesn't run normally? Is there a reason it's running in debug mode only?
Your question is worded somewhat confusingly so I'm not quite sure what you mean but I think you might be running into a problem with console.XXX() statements in your JS - on a browser that doesn't have console defined (like IE) or a Firefox installation that doesn't have Firebug, console will be undefined and your JavaScript code is likely to fail if you have forgotten to comment out your logging statements. You can verify if that is the problem by commenting out all calls to console (or by watching the console and looking for log output).
A long term solution might be to define the console object when your JavaScript initially loads if it finds that the console doesn't exist - this way, even if you forget to comment out calls to console and someone who doesn't have Firebug installed or is using a different browser tries to use your code, they won't run into this issue. Take a look at this blog post

JS Error in Internet Explorer

I'm getting "Object Expected JS error in IE 6 and 7. I'm not able to reproduce this always. The behavior is inconsistent. I'm using Dojo Charts in my JSP page. When this error occurs none of the Charts gets loaded.
I had a similar problem with IE before. That was a JS function was called before the JS file was loaded completely. We can see the JS file in the request, but that file is empty.
I wonder why IE is not taking the JS files from cache. It works perfectly in Mozilla.
Can some one suggest a better way to track such inconsistent JS errors?
thanks
You're dereferencing a variable which is undefined, but without an example, hard to say much beyond that.
(everything is an object in javascript so it's pretty much the only way to generate that error)
In Internet options in Advanced tab you can enable debugging.
IE has a lot of quirks that won't arise in other browsers. The best way to debug IE is to get a copy of Microsoft's Script Debugger, and you can launch it from IE to get a clearer idea of where the actual problem is. Script Debugger will halt execution at the problem line and show it in a separate window (IE locks up until you close Script Debugger, but you get a much better idea of what line is causing the problem).
See here for more: http://www.codestore.net/store.nsf/unid/DOMT-5UBUVW?OpenDocument
There's a link in the middle of that document that goes to MS Script Debugger, but here it is anyway.

Categories