javascript

Blocked vs Non-blocked Pop-up window

I found that, browsers don't block all pop-up JavaScript windows. How to write pop-up windows in JavaScript that won't be blocked by browsers? I mean what is the main factor that makes the difference? ...

Captcha reloading and animated icon synchronization problem

Dear web developers, I want to create a captcha in my website. I will try to describe how I want to do that. See the code below please: <img src=”captcha_img.png”> <img src=”reload.png”> <a href=”..”>Reload Captcha Image</> What I want to do is, to click on “Reload Captcha Image” link and with JavaScript change the content of the f...

How to highlight HTML text without wrapping it with tags?

Is it possible to highlight text in an HTML document using without wrapping it with <span> or any other tag for that matter? For example, in the HTML code <p>The quick fox</p> I would like to highlight quick but without adding a DOM element around it. Adding a DOM element to a parent element is fine. Thanks! ...

What are the possible ways to handle an expandable form using PHP?

I have a database that has two tables, one of which contains a foreign key back to the first. Similar to this: Table1 id description some other information Table2 table1ID Some other information For each table1 there can be any number of entries in table2. I need to create a form that allows user...

Javascript: Each Array

Note: No jQuery How could i do something like this: var array = new Array(); array[name] = "Tom"; array[age] = 15; foreach(array as key=>value){ alert(key + " = " + value); } ...

Loading multiple views from codeigniter using jquery

<script type="text/javascript"> $(document).ready(function() { $('a.menuitem').click(function() { var link = $(this), url = link.attr("href"); var newDiv = '<div></div>'; $("#content_pane").append(newDiv); newDiv.load(url); ...

Return value from GEvent.addListener in Google Maps API?

I am simply trying to get the distance from 2 points on a map using the Google Maps API. Using GDirections. The problem is that after the function finishes, distance is always null. I know this is because the "load" event isn't being called until after the function finishes. The Event Listener doesn't return values either so I am stumped...

Javascript - Which event to use for multiselect change

I'm using YUI as javascript framework, and can successfully react when the user changes the value of basic input fields, the reaction being to sent an Ajax query. However, I'm not so lucky with multiselect dropdown lists: listening to "change" would send my query each time the user adds/removes an item to his selection listening to "b...

Why can't I save an object's methods as properties of another object literal

The code below is used to note some methods to run in particular circumstances so they can be called using a simpler syntax. var callbacks = {alter: SPZ.sequenceEditor.saveAndLoadPuzzle, copy: SPZ.sequenceEditor.saveAsCopyAndLoadPuzzle, justSave:SPZ.sequenceEditor.saveAndLoadPuzzle}; But the code keeps retu...

Image Upload -- showing image on web page before hitting Submit

To better learn web development, I'm trying to write a PHP page that will let me upload and download files from a server, which I've done in ASP before. I am however, tripping over something that reason says should be simple, but I'm not able to find an answer for it. Here's the pretty standard code for the browse/submit: <form enct...

How to make this regexp work in javascript?

I'm trying to transfer the following URL validation function from my PHP code to my javascript code: this.validate_url = function(field) { var pattern = new RegExp("^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?"); ...

jquery create a unique id

hello, i have this code $(document).ready(function() { $('a.menuitem').click(function() { var arr = 0; var link = $( this ), url = link.attr( "href" ); var newDiv = $( document.createElement( 'div' ) ) $( "#content_pane" ).append( newDiv ); newDiv.load( url ); return false; }); }); As you can see i am creatin...

html string not being parsed with JSON.parse

I am using JSON.parse for a list of products. I am running a regex to replace characters that were breaking the parse: [\n|\t|\r] It seems that I am still having issues when the following content is being copied into html. <p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, Verdana, Helvetica; -webkit-bo...

unset session in Javascript

Does anyone know is it possible for me to reset/remove the session for php in javascript? ...

Object reference problem

Hi guys! Following problem: I would like to build a little clipboard with jQuery. I have tried several times to store an object in the data of a javascript object with $(object).data('id',objectToStore). Objects can be stored there that works fine. The problem is if I try to insert the stored data I only get a reference to that object....

Why is the result of my calculation undefined?

when I run the javascript code below, I get the variable original as ending as "1059823647undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined0" why is this happening and how can i fix it? original="012345678901234567890"; document.write("<textarea>"); document.write(original); document.write("<...

Javascript: document.execCommand cross-browser?

I just stumble on a piece of code which I never saw before (granted I can't call myself a JS expert): document.execCommand('Copy'); which seems to copy the clipboard contents to the element in focus. Q: Is this functionality available cross-browser? Edit 1: I found this interesting link. The page shows a compatibility matrix for do...

Connecting to a remote computer - desktop

I want to be able to connect (from a server) to a remote PC and be able to access it's files. I am trying to do this with PHP or JavaScript. So I am wondering if 1) it's possible and 2) how to do it. Does anyone have any examples/solutions? Thanks! ...

How to tell when an @font-face rule is applied

Is there any way to tell when an @font-face rule is applied? I'm creating @font-face rules that use data: URIs from a font file requested with an synchronous XMLHttpRequest in JavaScript and then write text to a canvas element using the font right away. The thing is that it doesn't actually use the font when drawing the text for the firs...

What is the best way of instantiating many JavaScript objects?

I need to create many instances of a specific class in a single page, and I'm wondering if the way that I define the methods of that class will have an impact on the page's performance. Does it matter whether I define the methods like this: function Foo(h, l) { this.h = h; this.l = l; } Foo.prototype.bar = function(x) { // do st...