Skip to content

Tag: html

How to get a number value from an input field?

I have some issues with calculating some stuff with JS and getting the right values out of the input fields (number). When I use this code it doesn’t show anything. So what is wrong with my JS? Do I need to include a jQuery file? Answer You had some mistakes in your HTML, but here is a working JSFiddle:…

Check if there’s some text inside an element

I am creating an If…Else statement and need to check if the element has innerHTML / textContent. Like this: So, how do I do that using Javascript? Please, help! UPD! I have dynamically changing content, and seems not working after I put some text inside my < span >. I mean it still thinks the <…

Set URL to load iframe in a Django template

I want to load an iframe into a Django template. The template is getting loaded correctly, but in place of the iframe, the template itself is getting embedded inside the parent template. The code relevant is given below: testgame.html is a file located in the same directory as this HTML template, but it doesn…

Communication between tabs or windows

I was searching for a way how to communicate between multiple tabs or windows in a browser (on the same domain, not CORS) without leaving traces. There were several solutions: using the window object postMessage cookies localStorage The first is probably the worst solution – you need to open a window fr…

JS Set background image of span

JS: HTML: I was wondering if it would be possible to also set the source of an image in this HTML from my Javascript code. So if I get “Item One” it will display that image in my HTML? Answer You just need to create an array containing the paths to your images such as var images = [“image1.p…

HTML5 Canvas Javascript how to make smooth brush

Hello i need make smooth brush likes this: I try to create it, i make circle and fill it, but result not successful: Can be seen circles.. this is not smooth like first example my example code: http://codepen.io/anon/pen/NPjwry Answer Try with a smaller globalAlpha and decrease the stepping (so you draw more …

Converting base64 to blob in javascript

I tried to convert a JPEG’s base64 string to a blob on a Cordova/hybrid app running on iOS 8 using the following function b64toBlob. However it’s giving an error when we do How can be work around this error? Answer Try this out. Please note that dataURI is assumed to include base64 prefix. (e.g. &…