javascript

How to get the file-path of the currenctly executing javascript code

I'm trying to do something like a c #include "filename.c", or php include(dirname(FILE)."filename.php") but in javascript. I know I can do this if I can get the URL a js file was loaded from (e.g. the URL given in the src attribute of the tag). Is there any way for the javascript to know that? Alternatively, is there any good way to lo...

parsing HTML with Firefox

uri = 'http://www.nytimes.com/'; searchuri = 'http://www.google.com/search?'; searchuri += 'q='+ encodeURIComponent(uri) +'&btnG=Search+Directory&hl=en&cat=gwd%2FTop'; req = new XMLHttpRequest(); req.open('GET', searchuri, true); req.onreadystatechange = function (aEvt) { if (req.readyState == 4) { if(req.status == 200) { ...

Persistent Data with Javascript

Hi, I have an application that has a "parent" window. In the parent window there are menu items, like the following (using PHP here): // sample link echo "<li><a href=\"#\" onclick=openurl('covershift.php');>Shift Coverage</a></\ li>"; // logout link echo "<li><a href=\"#\" onclick=openurl('logout');>Logout</a></li>"; Each link open...

Which web browsers give the most incompatability issues?

I'm not a 100% sure if I should be posting this here but where else can I post it (definitely not Server Fault or Super User) so hopefully it's not too inappropriate. I am currently developing a script that I hope to release as a plugin for wordpress and other open source content management systems. The script's purpose is to allow web ...

Javascript dispatchEvent

Hey... I'm using Flash a lot and my classes uses EventDispatcher class which allowes me to define custom events of a class. How can I do this in javascript. I would like to do something like this: var MyClass = function() { }; MyClass.prototype = { test : function() { dispatchEvent('ON_TEST'); } }; var mc = new MyClass(); mc.a...

sIFR 3 Leading and Kerning

I am trying to get leading and kerning to work on some sIFR 3 type on a site I'm working on (as described in the wiki: http://wiki.novemberborn.net/sifr3/Styling), but these two parameters seem to have no effect no matter what I do. I am not using intergers (no 'px' or 'em') just as it requires. I've also tried several different font...

is it better or group my ajax requests or send every request separately?

hello I'm developing an ajax project, but i'm confusing in something i have 3 functions that are sending data to the server every function has a certain job. is it better to group the ajax request that will be send from each function and send it in one big request. which will reduce my requests count & time. or send each request s...

get element after page loads

how do i call a function to count the number of divs with an id of 'd1' after the page loads. right now i have it in my section but doesnt that execute the script before anything in the loads? because it works if i put the code below the div tags... ...

Javascript extends class

What is the right/mest way to extend a javascript class so Class B inherits everything from the class A (class B extends A)? ...

jQuery dynamic form creation in IE8 not working with large amounts of data

At work, we have a report that is generated with IP's in it. There is a link you can click on in that report that will open a new window and call a script which brings up a google map with pin points to where each IP originates from. Depending on the report, it can return a lot of IP's (around 150 at times). So, in order for this to wor...

jQuery animate() to position issue

I'm just working on my personal website, giving it a bit of a revamp. I've implemented a sort of 'accordion' menu feature, where if a menu button is clicked, the "non-clicked" buttons disappear, and then the clicked button is moved to the top of the list, where then a panel animates down in which I will be putting text content. In Fire...

Overwriting iframe's document.write

For my own purposes (cough lazy-loading an ad script), I am overwriting the document.write function in order to buffer the script's output, writing it to a div, and restoring the native document.write when I am done. The pseudo-code looks something like this: save off native code document.write redefine document.write eval and buffer ...

Browser window centering problem

Hi, I am trying to launching a centered browser window via a form-button using the following code... Test button The new browser appears the correct height and width, but the left and top attributes are ignored, so the window appears top-left. Am I being too ambitious trying to make this code in-line? Is there any other syntax I sh...

Using max-width = 100% and max-height = 100% on an image, calculate the display width/height

I am creating a slideshow for images of various sizes to display centered vertically and horizontally within a canvas area. In my CSS, I set the width and height of the image to 100% so that each image would proportionally fill the canvas. I want the canvas to auto-size itself to fit within the viewer's screensize as the original size o...

Get current position of the viewport in Mobile (iPhone) Safari

I'm trying to position a div in the center of the iphone viewport. Basically so that when you hit an image, it pops up in the middle of the screen regardless of where you had scrolled to on the page before you clicked. It's not as simple as just making it position: fixed; as that will cause the origin to be the top of the page, not the ...

Cross-browser method for directory uploading

If this can only be done in some browsers, I'd still like to know how... Basically, I want to have a drag-and-drop feature where users can drag files to a drop zone and then hit "upload" and have the files uploaded to the server. I was pondering the possibility of having the option to drag an entire folder to the drop zone and uploadin...

XUL textbox addEventListener

I'm trying to detect when a user hits escape or enter when in a xul textbox (firefox extension). But the following code doesn't seem to work. Any assistance would be much appreciated. const KEY_ENTER = 13; const KEY_ESCAPE = 27; function keyPressed(e) { switch (e.keyCode) { case KEY_ENTER: // do something ...

What's an effective way to move data from one open browser tab to another?

I am looking for a quick way to grab some data off of one Web page and throw it into another. I don't have access to the query string in the URL of the second page, so passing the data that way is not an option. Right now, I am using a Greasemonkey user script in tandem with a JS bookmarklet trigger: javascript:doIt(); // ==UserScript==...

How to get the next letter of the alphabet in Javascript?

I am build an autocomplete that searches off of a CouchDB View. I need to be able to take the final character of the input string, and replace the last character with the next letter of the english alphabet. (No need for i18n here) For Example: Input String = "b" startkey = "b" endkey = "c" OR Input String = "foo" startkey = "fo...

way to load javascript code in web page

I prepare a project with a simple webpage, canvas, and javascript files that run game in the canvas. I want load my code when page starts, what is best way? put body onload? startup code in body of .js file (not in function)? attach to window load event? use some jquery capability? Thanks! ...