How to tell JavaScript to execute a function after an element has been loaded w/out any external library? Normally I have to bring the <script> tag after the element itself to work with DOM calls. Answer Well you can utilize the document.onload and window.onload methods For example:
Category: Questions
what encoding this is?
can anyone tell me what encoding is applied on the chinese character, so that chinese characters are converted into this code or text and stored in mysql database : original chinese characters which are displayed in web page : on the web page there is a header function is used to make standard chinese chars as follow: Thanks… Answer When
Prepend text to beginning of string
What is the fastest method, to add a new value at the beginning of a string? Answer Wouldn’t this work for you?
Maximum size of a element
I’m working with a canvas element with a height of 600 to 1000 pixels and a width of several tens or hundreds of thousands of pixels. However, after a certain number of pixels (obviously unknown), the canvas no longer display shapes I draw with JS. Does anyone know if there’s a limit? Tested both in Chrome 12 and Firefox 4.
Why is my .data() function returning [ instead of the first value of my array?
I want to pass an array into a jQuery data attribute on the server side and then retrieve it like so: Why does this appear to alert ‘[‘ and not ‘a’ (see JSFiddle link) JSFiddle Link: http://jsfiddle.net/ktw4v/3/ Answer It’s treating your variable as a string, the zeroth element of which is [. This is happening because your string is not
Json file gives 403 error on server
I have a json file contianing data which I access through javascript. On my virtual MAMP server on mac It works, but on my online server when I load the HTML file I cant access the json file from javascript. I get 403 no permission for access error. Why? Answer If your production server is Linux based then please consider
Issue regarding live event
I was just reading http://api.jquery.com/event.stopPropagation/ Since the .live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live events I was a bit confused with this statement, Can someone please explain me the same with some example? Answer Live method binds a handler to the document, and identifies
How do I detect “shift+enter” and generate a new line in Textarea?
Currently, if the person presses enter inside the text area, the form will submit. Good, I want that. But when they type shift + enter, I want the textarea to move to the next line: n How can I do that in JQuery or plain JavaScript as simple as possible? Answer Better use simpler solution: Tim’s solution below is better
What is the difference between properties and attributes in HTML?
After the changes made in jQuery 1.6.1, I have been trying to define the difference between properties and attributes in HTML. Looking at the list on the jQuery 1.6.1 release notes (near the bottom), it seems one can classify HTML properties and attributes as follows: Properties: All which either has a boolean value or that is UA calculated such as
Substring text with HTML tags in Javascript
Do you have solution to substring text with HTML tags in Javascript? For example: Answer Taking into consideration that parsing html with regex is a bad idea, here is a solution that does just that 🙂 EDIT: Just to be clear: This is not a valid solution, it was meant as an exercise that made very lenient assumptions about the