Skip to content
Advertisement

Tag: javascript

How to write this crawler in JavaScript?

The idea is very simple: Imagine a simple white page with a form with a single input tag (like Google homepage ). When I insert a link of a blog post in this form, then the javascript-crawler search the first image in the web page of the blog post (through ajax), show it in the white page and save it

Dynamic Ad script Replacing Page

I have an application that uses a mobile ad provider; the way ad provider works is that I make a request on the server side, the provider returns me the mark-up and I include that on my site. In order to make the load page faster (which is a requirement that I don’t control), I have an AJAX call to

JavaScript add events cross-browser function implementation: use attachEvent/addEventListener vs inline events

In order to add events we could use this simple first solution: or this second solution (that adds inline events): These are both cross-browsers and can be used in this way: Since I have the feeling attachEvent/addEventListener are used more around in events handling implementations, I’m wondering: Are there any disadvantages/drawbacks against using the second solution that I might better

How to generate sequence of numbers/chars in javascript?

Is there a way to generate sequence of characters or numbers in javascript? For example, I want to create array that contains eight 1s. I can do it with for loop, but wondering whether there is a jQuery library or javascript function that can do it for me? Answer You can make your own re-usable function I suppose, for your

On Text Highlight Event?

I’m curious if anyone knows how I would trigger a function to run if/once the user finishes selecting text on the web page? I would like the user to be able to select text, and after a short delay(or immediately, at this point it doesn’t matter much) an overlay button appears near the text that the user can then click

HTML input fields does not get focus when clicked

I have a problem and I can’t figure out what exactly is causing this behavior. I cannot access my input fields and textareas on my HTML form. Unfortunately, the JS, HTML and CSS are very large, so I can’t really post it all here. Can anybody tell me what to look for when debugging this strange behavior? UPDATE If I

Append Style to DOM not Replacing Existing

How can I append style element to DOM without eliminating existing style on the item (eg color, text-align, etc)? The event calls the function, but the problem is ‘Style’ gets completely replaced with the single item instead. I have simple code triggered on the event: Answer Which browser are you using? In Chrome, this works for me: When I click

JavaScript file upload size validation

Is there any way to check file size before uploading it using JavaScript? Answer Yes, you can use the File API for this. Here’s a complete example (see comments): Slightly off-topic, but: Note that client-side validation is no substitute for server-side validation. Client-side validation is purely to make it possible to provide a nicer user experience. For instance, if you

Advertisement