Skip to content
Advertisement

Tag: javascript

this.name returns undefined in javascript

I am trying to remotely create an onclick for each <div> (to save typing time). Here is the window.onload() function: The name of every <div> is “flyingsheep” – this value was set by <div name=”flyingsheep”>. When I click the <div>, the iframe “game” takes me to the webpage “/games/undefined”. Answer This will work. the problem is corrected. just use :

How to wait until an element exists?

I’m working on an Extension in Chrome, and I’m wondering: what’s the best way to find out when an element comes into existence? Using plain javascript, with an interval that checks until an element exists, or does jQuery have some easy way to do this? Answer DOMNodeInserted is being deprecated, along with the other DOM mutation events, because of performance

CodeMirror 2 – Highlight only (no editor)

Can CodeMirror 2 be used to highlight code from a DIV or PRE tag (without the editor)? Like CodeMirror 1 used to be able to do with the hightlightText() function? For example here: http://codemirror.net/1/highlight.html, after you press run highlight (the highlighted text below) Also can it highlight code from a inline element, like <code>, and keep the results inline, like

Expand Image Vertically Without Disrupting the Flow with Javascript & CSS

My Progress is @ http://codebucket.webatu.com/code/portfoliotest/index.html Code on JSfiddle: http://jsfiddle.net/warmlaundry/qJbG4/70/ I want to make the edges of the ‘f’ and ‘l’ stretch to the edge of the page. I’m just expanding the height of two images that sandwich the word. I want the word itself to stay put, and I don’t want the expanding images to displace any other elements. Is

String length in bytes in JavaScript

In my JavaScript code I need to compose a message to server in this format: Example: The data may contain unicode characters. I need to send them as UTF-8. I’m looking for the most cross-browser way to calculate the length of the string in bytes in JavaScript. I’ve tried this to compose my payload: But it does not give me

Convert string to datetime

How to convert string like ’01-01-1970 00:03:44′ to datetime? Answer For this format (assuming datepart has the format dd-mm-yyyy) in plain javascript use dateString2Date. It may bite you, because of browser compatibility problems. tryParseDateFromString is ES6 utility method to parse a date string using a format string parameter (format) to inform the method about the position of date/month/year in the

Are there anyway to prevent frame override main window?

I have html page with frame where I want to show some web pages/sites. There are some sites like www.yandex.com which popup from frame and become main window. I want to find some solution to intercept some event or something like this to prevent such subframe activity. Is it possible? Answer You can listen to the onbeforeunload event, which fires

Advertisement