javascript

jQuery - If I'm moving a div with the keyboard...

Yo! If I have a div with a fixed height and width, which I am moving using keypress (or keydown/keyup). Can I get the window to "follow" that div? I know you can auto scroll a page, but can you get the co-ordinates of a div and scroll the page as the div moves? Cheers :) ...

How to load a script into a XUL app after initial loading

Greetings, my xul app needs to load scripts dynamically, for this I derived a function that works in regular html/js apps : function loadScript(url) { var e = document.createElement("script"); e.src = url; e.type="text/javascript"; document.getElementsByTagName("head")[0].appendChild(e); } to something that ought work in XU...

How to properly move jQuery from index page, into separate javascript file?

How can I move my initialization code i.e. <script type="text/javascript"> $(document).ready(function() { var t; // This will be a timeout $('.navHover').mouseover(function() { if (t) { clearTimeout(t); } $('.navigation...

Rails: Get the image src only

Hi all, Does rails have a way to get JUST the src of an image as a string? I'm trying to embed the image on a third party site in javascript. This is the general idea (widget.js.erb): var widgetImage = new Image(); widgetImage.src = "<=% Some groovy ruby code to just get the image src as a string %>" Any ideas? ...

Bogus (Yet Crippling) "[WebElementId] is not declared" Error In VB.NET

So I have the error mentioned in the title when I try to build my web site through the file menu. The code that causes this is below (JavaScript that appears in the body tag): if(editedRow != null) { var SundayLoc = $find("<%= FieldOpsScheduler_ctl00_ctl05_RCB_SunLocale.ClientID %>"); ...

How do I write the following code as a for loop?

Firstly, Is there a way for me to put variable declarations in a for loop? E.g. the following: var origh1 = $('#candidates img:eq(0)').height(); var origh2 = $('#candidates img:eq(1)').height(); var origh3 = $('#candidates img:eq(2)').height(); var origh4 = $('#candidates img:eq(3)').height(); var thumb1h = $('#candidates img:eq...

Sending/Displaying a base64 encoded Image

Hi Folks, I need to send a base64 encoded string to a client. Therefore, I'm opening and reading an image file on the server, encode it and send that data along with the image/jpeg content-type to the browser. Example in php: $image = $imagedir . 'example.jpg'; $image_file = fopen($image, 'r'); $image_data = fread($image_file, fi...

Ruby on Rails: At what point do you write raw javascript instead of using rjs templates?

As a new comer to writing front-end views with Rails, I'm a bit confused as to when I should be using rjs templates versus when I should be writing my own JavaScript to handle events/DHTML. Is there some rules you avid Rails developers follow for when something is too complex or not possible with RJS and you just write the JavaScript you...

Select Element By CSS style (all with given style)

Is there a way to select all elements that have a given style using JavaScript? Eg, I want all absolutely positioned elements on a page. I would assume it is easier to find elements by style where the style is explicitly declared: the style is non-inherited (such as positioning) the style is not the default (as would be position:sta...

Output JSTL escaped?

I am retrieving a value from our DB using JSTL. I am inserting it right into some javascript to use it as a variable. I need the output of the value the JSTL is holding to be escaped because if there are single or double quotes it breaks my script. The value is user specified. Example: Doing the following: <c:set var="myVar" value="Da...

VERY confused - javascript not being executed - unless Console is turned on in Firebug?!

Hey everyone! I just started doing some Javascript work for a project, I do mostly backend work so I'm sorry for being new at this! Also, not using a Javascript framework because I want to learn about the fundamentals before making everything very easy for myself :) So, here is my question/confusion: I wrote a little javascript that dy...

Regex to include all intranet sites but exclude http(s)://localhost

Hi, I am trying to come up with a JS regex that will include any intranet site (with the simple definition of any host name that does not include .), but will exclude localhost. I've got the first part: http(s)?\:\/\/[^\.\/]+(\/.*)* I am struggling with the second part. Any help would be appreciated. ...

JavaScript doesn't work in my frames?!

Hey! I am making a homepage at the moment and I have made an edge around the "main page" with frameset... that was probably stupid, but now my JavaScript for some reason doesn't work?! What I want to do is make a username and password protected page using javascript. The script itself is as follows: function logIn(); { var username ...

MediaRSS parsing in Javascript

I'm trying to read the Flickr feed in order to parse the images. However, the images are in the media:thumbnail tag. Where would I begin to make a mediaRSS parser? Does anyone have an example? ...

Google Maps API -- Why isn't this working?!?!

So I'm making a Google Maps based webapp in JavaScript and a part of my code looks like this: function revGeocode(marker){ var latlng = marker.position; if (geocoder) { geocoder.geocode({'latLng': latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (result...

jQuery Delaying Queue

I want to delay things like the css from happening but this method wont work. Any ideas on how I can delay tasks. $(function() { $('.btn').click(function() { $('.divOne').animate({"left": "+=400px"}, "fast").delay(800).css("background-color","yellow"); }); }); ...

Internet Explorer strange text selection behavior - cannot select fragment of text containing whitespace

I need to enable selecting certain fragment of text in IE for further JS processing. Unfortunately, IE has strange text selection behaviour - when you try to select text fragment that contains whitespace, IE will extend selection to the whole words, e.g. if you try to select (using your mouse) only: rem ips fragment from the sentence: L...

How do I modify my code to collect form input from a popup and insert it into a textarea at cursor location on original page using JavaScript?

The JavaScript shown below inserts form input into a textarea at the current cursor position. The textarea id=mbentry. This works if all code is on the same page. I want to have a hypertext link on page1.php open a little popup window (page2.php for example) so the user can enter text in the popup, close the window and have the input fr...

greasemonkey: addEventListener questions

I've a userscript as the following: document.addEventListener('click', alert('hello monkey'), true); There were two problems: "hello monkey" is alerted only when refreshing the browser, not work when clicking window. using GM's 'manage user script' to edit the script, the change doesn't happen. (The source code on the local disc was...

changing the value using javascript or jquery..is it even possible?

hi I am looking for a way to change the value what I passed to function once a button is pressed <span id="showHidden" style=" margin-left:726px; position:relative; top:40;"> <input type="image" id="btnShowHidden" src/images/hide.gif" onclick="showHiddenRecords(1);" /> </span> As you see in showHiddenRecords, its ...