javascript

Javascript utf-8 substr and length function

Hello, I am trying to do a substr on a UTF-8 string like हिन्दी. The problem is that it becomes totally screwed up=> with some weird box in the end (does not show here, although i copy pasted) (its something like [00 02]): हिन... okay this is how it appers after using substr function: Wondering if there is some function to solve th...

JavaScript: Quickly insert text into long textarea

I am playing around with creating an HTML-textarea based plain text editor to edit my scripts (using e.g. Mozilla Prism + a localhost install/ webserver). It works fine so far, but when I want to insert something at the cursor position, it gets slow in Firefox when there is a lot of text in the textarea (Chrome works fine). E.g. with 133...

Onclick function that mails page url to admin

I need to create some kind of JS onclick that will run a php mail script that emails a page with broken content. Would it be best to run a normal javascript onclick that calls a php file which is hidden, grabs the referring url and emails it? I would also like a message confirming the click, then disable it. Is there anything like thi...

How does push email/chat work? Can it be implemented easily for small websites?

I am trying to understand how push services work. I believe push notifications are where the server 'pushes' a new item to the client, but I don't know how that works in practice. For example, how does a phone "know" that it has a new email to pick up if it doesn't manually check the server for a new message? Also, how can this be impl...

cancel mouse events

i'm using a mouse event for an outer element. how to cancel the from triggering by sub elements with reasonably small code <div onmouseout='myfunc()'> <div>item1</div> <div>item2</div> ............... <div>item n</div> </div> mouseevent should not apply to item1 to n ...

Suppose I have this javascript function. How do I pass the element to it?

function getLeftPos(elm){ var left = 0; while(elm){ left += elm.offsetLeft; elm= elm.offsetParent; } return left; } How come this doesn't work? getLeftPos(document.getElementById("#frame")); If I alert(elm) inside that function, it is NULL. ...

How to gain access to an element on the same level in the DOM?

<div id="dad"> <img id="mum"> <input> </div> With jQuery, how could i get access to the input element, get is value or set it for example? I can't work out how to access something on the same level.. and i dont want to be using ID's, just parent/child nodes so i can use the code for loads of dad div's Thanks! ...

ASP.NET Treeview - Add Node through Javascript

Hi I'm using ASP.NET Treeview Control, and I was wondering if it's possible to dynamically add child nodes using Javascript ? ...

XHTML won't validate && and < in a JavaScript function

Here's the snippet of code that won't validate: if (user_age > 15 && user_age < 91) It gets the following errors: XML Parsing Error: StartTag: invalid element name and XML Parsing Error: xmlParseEntityRef: no name The first error is thrown for the "less than" and the second one is thrown twice, once for each ampersand. Replacin...

Tinymce - insert html code

Hello folks, I would appreciate if there is someone who can help me solve this problem, I've been trying to resolve it for few days, but with no success. I made custom button that inserts image into code, and here is textual version: <a href="javascript:;" onmousedown="tinyMCE.execCommand('mceInsertContent',false,'<br><img alt=$img_titl...

When are javascript functions executed

Hi, I think it has to be an easy question but I have been searching around and have not found the answer anywhere. The think is that I have an html page with some scripts (in the body) like this one: <script type="text/javascript">grf();</script> The grf() function is defined in an external .js file. The question is: is this function...

How can I disable JavaScript warnings in the WebBrowser control?

I'm using the WebBrowser control and mshtml.dll. When I simulate click on link <a href='..'>..</a>, the WebBrowser shows a JavaScript warning dialog: Unable to move the focus to the element as it is in the invisible ,off or can't have a focus. The code I use to simulate the click: anchor.click(); ...where anchor has the type: ...

Implementing isInstance in Javascript

I define how two functions can inherit from each other as follows: Function.prototype.inherit = function(parent){ function proto() {} proto.prototype = parent.prototype; this.prototype = new proto(); this.prototype.constructor = this; this.prototype.parent = parent; } I then need to define an isInstance function that would behave l...

Request data from database using Django

I have somehow two variables for example x and y. I have also made a model with 3 fields (longitude,latitude,name) and have it activated in mysql database. I need to send these two variables(x,y) to the django server so as to search if there is an object with longitude=x and latitude=y.If there is one i want to get back it's name. How c...

Custom Search Provider for IE7 using javascript: call - is it possible?

I would like to create a custom search provider for IE7 or IE8 that is not requesting a URL with the search string as a parameter, but calls a JavaScript function instead, passing the search string as an argument to the function. To get started, I tried something really simple in my search provider XML: <Url type="text/html" method="get...

Is it possible to set the width of an element to that of the preceding element?

My input elements are followed by a div. I would like to set the width of that div to be that of the preceding input element. <input type="text" class="input" size="100" name="data"/> <div class="inputHelp"> enter data above </div> <input type="text" class="input" size="80" name="moredata"/> <div class="inputHelp"> enter more data abov...

how to list GET with JS

i need to know how to list GET requests with JS ... i have this : window.location.pathname.search ... ???? ...

Is there a javascript way to check if a browser natively supports MP3?

that's all really. If the browser can play MP3's then I'll use the audio tag to play a file. If not, I'll have to load in a flash player. ...

How to darken a DIV surrounding using JQuery (lightbox-like, but no pop-up) ?

I want the user to focus on a part of the screen at a given time. The idea is to fade everything on the Web page but the required DIV, so the user will be invited to work in this area. The effect I am looking for looks like a lot a lightbox, except there is no pop up, and no content is loaded, the only changing thing is the look and fee...

Test browser history before going back via javascript?

I'm playing around with using some javascript to add extra functionality to a back button on my website. Right now I have a set of javascript that looks like this: $(".back-link a").live("click", function(){ history.go(-1); return false; }); Now, it works great but I'm trying to make it as bulletproof as possible and one issue...