i have problem obtaining globalPagefrom safari.extension inside injected script.
Every time i try to get it safari returns error in console:
TypeError: Result of expression 'safari.extension.globalPage' [undefined] is not an object.
Inside Global Page script i don't have problem obtaining it.
Does any one of you know how to resolve this issue ?
Thanks
You can't directly access globalPage from an injected script; you have to use message passing to access any globalPage objects. Read this section of the Safari Extensions Dev Guide. Comment if you need tips.
Related
I keep getting this error in Firefox console.
onmozfullscreenchange is deprecated. editresume.js:411:4
onmozfullscreenerror is deprecated. editresume.js:411:4
Ignoring get or set of property that has [LenientThis] because the “this” object is incorrect.
If I go to my code file, for that line number, this is what I have
tempbutton.setAttributeNode(attid);
and, I am not using onmozfullscreenchange or onmozfullscreenerror anywhere.
Why am I getting this? It is also triggers a debugger exception for some reason, at that line number.
Note : I dont get a similar error/warning/breakpoint trigger on Chrome. So, its Firefox only.
Firefox version - 70.0
Chrome version - 77.0.X
This message may appear when logging the window or document objects and extending the resulting message in the Console.
It's because these getters are configured to warn about this deprecation so that developers can update their code accordingly.
However, this deprecation notice doesn't look at what tried to get it, so when the Console itself tries to get the value of these properties, it will also trigger the warning notification.
But your debugger exception certainly comes from somewhere else.
The object {'1':'test'} gives an error in Firefox, but seems to be fine in Chrome. Does anyone know how to get around this error and make this work? The keys and values are from an external source so I can't just change them. (Run the code snippet below in Firefox and you will see the error.)
{'1':'test'}
You have to save the object in a variable or use it in any way. Just writing in inside a script block does nothing.
The following works fine:
var obj = {'1':'test'};
alert(obj['1']);
I tried in chrome console and firefox console.
Indeed, that doesn't work in Firefox, but, it's normal.
In javascript you can't type JSON without variable declaration before.
So, Firefox doesn't understand it because javascript doesn't understand it.
In fact, I think that Chrome overrides the javascript interpretor to allow declaration without attributions.
Like in python shell when you type 5, it will write 5. So with that Chrome allow you to see the structure of an array or object whatever, just by typings them without declare it into a variable.
You can see an example here :
https://jsfiddle.net/3yqdj599/
let yes = {'1':'test'};
console.log(yes)
// {'1':'test'} => that doesn't work
Finally, don't worry, since a browser is able to execute javascript, if you assign your object in a variable, it will interpret it.
I hope this is clear and helped you ! :)
Cya !
I have javascript error tracking on my website. Recently I started getting the following error from Chrome (versions 37 and 38) on iPhone (IOS 7 and 8):
ReferenceError: Can't find variable: __gCrWeb
I couldn't find any useful information about this error except for a few references. Has anyone seen it before and knows why it happens?
__gcrweb is a reference by gcrweb.js, which is a local (on device) js getting injected by the iOS version of Chrome.
Google needs to do this for some extended functionality (mostly inserting/retrieving login credentials and other form information you stored via another synced Chrome browser) which isn't provided by the native webview it's built on and can't be added to it otherwise.
This should not affect any parts of your code and i'd get rid of it by ignoring it in your error logging (the error should always be the same string), for example:
https://docs.sentry.io/clients/javascript/config/
https://rollbar.com/docs/notifier/rollbar.js/#ignoring-specific-exception-messages
Another solution could be to make sure that the reference always exists by declaring it yourself at the beginning of your js init
if (!window.__gCrWeb) window['__gCrWeb'] = {};
just like Google does it.
I am navigating an object that contains an array of objects.
When I use chrome's js developer console I can grab the title property from the first item in the array i.e.
hello.example.array[0].title
this returns the title (only in the js developer console). However when I write a script to do this for me suddenly I receive this response:
Cannot read property 'array' of undefined
here is an example of my js
var theTitle = hello.example.array[0].title;
console.log(theTitle);
Why does the console find it correctly when my js does not?
Try selecting the expression in question in the script view and then use the Ctrl-Shift-E shortcut to evaluate in the console. Or, copy-and-paste from the script view into the console. Or, hover over the last component of the expression in the script view to see the value. In either case, you will most likely find that you've mistyped something, or are executing the script in a different context than that in which you are evaluating the expression in the console, etc.
Thanks to #Barmar, I realized I needed to view how I was going about grabbing the 'title' property.
My solution was in the context of other code and how the object was being created in the first place.
Thanks all for the help!
Edit 6 Years later:
This post has some popularity so I thought I would update it with a more valid answer...
Make sure your JavaScript actually has the scope/context of the object to begin with.
The JS Console is able to return it because it is being executed after the code has run.. whereas the JavaScript in question might be trying to access the variable before it is set.
So check if you have the right scope/context and that the code is not trying to access a variable before it has been set.
I started to test my web site on google chrome and
'cannot call method 'join' of null'
appears when doing this:
var sChoices = oQuestion.aChoiceRand.join("");
In IE and FF works well. What I'm trying to do with this code is to join all the aChoiceRand array elements in a string without any separators. How can I solve this?
The problem's cause must be earlier, when oQuestion.aChoiceRand gets assigned: you think it's assigned to an array (and apparently IE and FF agree with you), Chrome is telling you that it's null instead. We can't really help without seeing the code that's supposed to assign oQuestion.aChoiceRand its value...