Basically, I want to change the picture of the blue bridge in the center to the profile picture of the user. I've tried to do this by doing id.style.backgroundImage="URL". But the original background image persists.
function onSignIn(googleUser) {
var face = document.getElementById("circleface");
face.style.backgroundImage = "profile.getImageUrl()";
var profile = googleUser.getBasicProfile();
var profileName = document.getElementById("googleName");
profileName.innerHTML="Hey "+profile.getName();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
@Phoenix Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
I have a (nested) data structure containing objects and arrays. How can I extract the information, i.e. access a specific or multiple values (or keys)?
For example:
var data = {
code: 42,
items: [{
id: 1,
name: 'foo'
}, {
id: 2,
name: 'bar'
}]
};
...
Hello, is there any way of outputting JSON objects as string in HTML without them getting encoded to escape quotes? I'm using JSON.stringify(obj); and getting this output: {"1":false,"2":true,"3":true,"4":false}
> For Chrome: Create an XMLHttpRequest with responseType 'arraybuffer' that gets a size X from Content-Length header or X from a ProgressEvent's total attribute but response.byteLength Y; Y is smaller than X. You may write the URL endpoint you're making a request to.
I will repeat this until someone figures this out :D
Hey guys (and girls) :) ... I'm looking for a way to make a tampermonkey user-script for my Firefox v56, where it will 'insert' one button on a webpage and when I click on it, it will paste the clipboard content into <input> field. I asked the question but it was marked as duplicate, here: https://stackoverflow.com/questions/50323091/
I was being told that its not possible without creating an extension. But...can some of you check my question and see if there is a way without creating any extra extesions (addons) for Firefox. I just need a 'simple' script that can paste from clipboard into…
@sarah997 Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
something
.then((a) => { stuff with a })
.then((a) => { more stuff with another a })
// vs
const a = await something;
stuff with a
const a = await something that emerged from stuff with a
oh wait there's an error
@BenjaminGruenbaum I know that you mean util.promisify, and it's very helpful
I guess with async/await, in the specific case of an error, the scope doesn't leak because of the try/catch block
but then maybe you want to do some other api request in the catch, which might also fail, and you're back to square 0
and even then, I'm not going to spend hours now converting the codebase to promises
thought that there's probably another elegant solution out there
@towc You're not making any sense. That's not "scope leak" it's the fact then callbacks have to run in a function - it's a limitation and certainly not a feature. Also "oh wait there's an error" implies you don't understand error handling in async/await or atre being unclear
it's a possibility, but for it to do stuff, it would need to use unnecessary mutability anyway. In which case you'd want to put that in a smaller function anyway
and at that point you would just want to use promises
I'm not even sure what to say to that other than that you've not demonstrated that it's a problem or that it's even a worth-discussing tradeoff. It sounds to me like you're just inexperienced with either async/await, promises or both
Hello everyone. I was hoping someone could help me out. I need to set a cookie if the customer clicked on the megaMenu. This needs to be false by default and the set to true on the next page if the customer clicked on a menu button. Any help would be appreciated
@SurajJain same origin means you can access the data - an img tag gives you opaque data. If you want to actually process it (in a canvas for instance) you need the appropriate CORS headers
So it is not exception right, we cannot read the image, if the origin is different we cannot read imagw though JavaScript it will be rendered but we cannot read.
"Same-Origin Policy (SOP) does not make CSRF impossible but it somehow limits the impact of CSRF in that the request gets send to site B but the result returned by the server of site B can not be seen by the attacker. Thus SOP makes CSRF write-only, i.e. CSRF can be used to execute unwanted actions but it cannot be used by itself to exfiltrate data from site B. "
In image case and script case too this happen we can not read image content, if try to read it with canvas will get error and we can execute script but cannot read its contents.
"Note that SOP does not prevent resources hosted on different domains to be embedded in a page by using script tags, CSS and image tags." <-- that's correct.
I found this error using socket.io latest version: "index.js: 83 POST http: //localhost/socket.io/? EIO = 3 & transport = polling & t = MDUHEO9 404 (Not Found)". I understand the reason: the true address must be http: // localhost: 3000 / socket.io /. Do you know how I can correct?