Javascript Error: n is null in swfobject.js - javascript

My Web application renders me "n is null" Javascript error in firefox browser when i try to access a particular page. This error originates in swfobject.js file.
Also i get another Javascript error "a is null" in firefox browser when i try to access a particular page.This error originates in MicrosoftAjax.js file.
Any help would be deeply appreciated.
Thanks.

Your problem may be that the code is trying to access an HTML element that has not loaded yet.
To resolve this try wrap the code that is getting the errors in a jquery ready block if you are using jQuery:
$(document).ready(function () {
//Code that uses SWF/MicrosoftAjax here
});
or if you are not using jQuery:
window.onload=function() // fixed windows to window
{
//Code that uses SWF/MicrosoftAjax here
}

Use firebug to pinpoint the problem.
99%, the problem's origin is not swfobject.js but in some script that's loaded before it.

Related

browser.alarms is undefined using webextension-polyfill

I'm trying to create an alarm using browser.alarms API for web extensions.
To make the extension cross-browser, I am using webextension-polyfill and testing on Chrome.
My code to create an alarm within a background script is shown below:
browser.alarms.create('spline-items-notification', {
periodInMinutes: 1
});
However, when I attempt to run this extension, I always get an error:
Uncaught TypeError: Cannot read property 'create' of undefined
I am loading webextension-polyfill before the background script in manifest.json, and other interfaces work, like browser.notifications.
I would like to know how to fix this if possible. Thank you.
alarms
To use this API you need to have the "alarms" permission.
Does the manifest.json have the "alarms" permission?
I think this a bug with webextension-polyfill, but I opened a pull request that should fix it.

How can I embed this snapppt javascript?

I'm trying to embed a javascript from snapppt.com into a cms page. It shows me in console that the script has been loaded, but there is nothing showing up.
This is the code i get from snapppt.com:
<script src='//snapppt.com/widgets/widget_loader/724028e3-d261-411c-8042-c1901fbc8ad7/carousel.js' class='snapppt-widget'></script>
Do I need anything in addition to this?
I've tried to use the script and i get error in the console
Uncaught TypeError: $ is not a function carousel.js:69
I think that you use the code correctly but there is some error in the script that you are loading

Why is chrome.runtime undefined when running JS inside a page from a content script?

I am creating a Google Chrome extension (my first one) and I want to send messages from the extension to the current tab.
I am following the documentation:
https://developer.chrome.com/apps/runtime#event-onMessage
The extension loads a small external JS into the tab's HTML, which contains the following code:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
console.log(request)
}
);
As soon as the JS is loaded I get the following error:
Uncaught TypeError: Cannot read property 'onMessage' of undefined.
Opening console and typing chrome, I can see that the runtime is not a property of chrome.
It looks like I am doing something wrong, but what? Do I need to add something to the manifest.json file?
Chrome Version 39.0.2171.71 m
Thank you.
If you're inserting JavaScript into a page with a <script> tag, it executes in the page's context.
Sometimes it is desirable: that's the only way to access page-level JavaScript objects.
But in your case it means that the code does not have access to Chrome APIs, as it is "the same" as the page's code.
You need to look into communicating between page-level and content scripts, or between page-level and background (spoiler, in most cases needs a context script proxy anyway).
or it could just be a Heisenbug which only appears under certain circumstances. in my case, closing the chrome://extensions tab and refreshing my target caused chrome.runtime to be available again. Why is chrome.runtime undefined in the content script?

Error - Permission denied - jQuery Print Preview?

When I click "Print" using the jQuery Print Preview Plugin the following error pops up and Firebug:
Error: Permission denied to access property 'name'
if (window.frames[i].name == "print-frame") {
I am not sure exactly what it means or how to correct it.
There is a way around this that will solve this problem and work properly with all major browsers. This solution was found by Derick over on the Github page for jQuery Print Preview.
Here is the solution, around line 44 you will see the following code:
// The frame lives
for (var i=0; i < window.frames.length; i++) {
if (window.frames[i].name == "print-frame") {
var print_frame_ref = window.frames[i].document;
break;
}
}
Replace the above code with this:
print_frame_ref = print_frame[0].contentWindow.document;
issue solved.
Here is the error in Chrome, I expect this makes it clear?
Unsafe JavaScript attempt to access frame with URL http://s7.addthis.com/static/r07/sh090.html#iit=1341762779832&tmr=load%3D1341762779182%26core%3D1341762779520%26main%3D1341762779826%26ifr%3D1341762779833&cb=0&cdn=0&chr=UTF-8&kw=&ab=-&dh=www.ubhape2.com&dr=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F11384440%2Ferror-permission-denied-jquery-print-preview&du=http%3A%2F%2Fwww.ubhape2.com%2Ftest-print.html&dt=TEST%20Page&md=0&cap=tc%3D0%26ab%3D0&inst=1&irt=0&jsl=33&lng=en-US&ogt=&pc=men&pub=ra-4dfb00d56c76d2a5&ssl=0&sid=4ff9acdb1a41cc60&srd=0&srf=0.02&srp=0.2&srl=1&srx=1&ver=300&xck=0&xtr=0&og=&rev=114791&ct=1&xld=1&xd=1 from frame with URL http://www.ubhape2.com/test-print.html. Domains, protocols and ports must match.
Your page is located on ww.ubhape2.com and you are accessing a frame on s7.addthis.com
To fix this problem, change this line
<script type="text/javascript" src="https://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4dfb00d56c76d2a5"></script>
To point to the copied script on your site.
You will also have to edit that script to only access your own site.
This is an example of XSS or cross site scripting.
My question then turns into can I edit the jQuery Print Preview Script
to prevent the conflict from happening?
No.
The point of the error is that the javascript is running in the context of another party, and you can't "inject" your code into it.
This is enforced by the browser.
If it was not enforced then every user on the internet would have had their machines compromised.
Read up on a google search of XSS to find out more
However,
If you host the javascript (and thus the iframe) on your server than the issue goes away. It is your code (and your iframe) to do with as you wish.

What does Firebug "XML cannot be the whole program" error message mean?

I just got this error message in Firebug. A google search reveals nothing but other mystified people! Does anyone have any idea what it means?
It's being indicated on the last line of this 3-line script:
<script>
g_BuildServer = "/";
</script>
If you put JavaScript in a js file (which I assume you did), do NOT put the script tags, put
g_BuildServer = "/";
only.
Otherwise, to the parser, you just provided an XML document as a script.
I got this error when using jquery $get with no data type attribute when it was retrieving html. I added the dataType parameter as "html" and it fixed the issue.
Happened to me too, just for having an empty script tag in the page. When I removed this:
<script src="" type="text/javascript"></script>
everything got back to normal..
I got the "XML cannot be the whole program" error because the server was returning an xml error message in response to a request for a javascript file. My case may be unusual, but here it is:
I had a servlet filter granting or denying access to server resources. If it grants access, you get the resource, otherwise, you get <filterResponse><Access_Denied/></filterResponse>. I had failed to add the javascript file to the list of resources you don't have to be logged in to access. So, when Firefox received an XML error message as the body of a javascript program, its complaint makes perfect sense.
I experienced this error when I had a comment in my javascript but it didn't start with a /*
it just had a few *'s hence creating a syntax error
Also you can get this error while you use jQuery.
In that case replace "$" with "jQuery"
It also happens, when you use jQuery's template plugin, and you place the markup in a script tag, but you forget to change the script tag's type attribute to 'text/x-jquery-tmpl'

Categories