javascript

Button with image and loading element id when clicked

Hello guys, I've made an application that makes full use of ajax, and what I need to do is: I want a button with a description + image that when clicked is disabled and instead of the original image in the button, appears the ajax loading element id inside the button. And when the ajax loading is complete, the original image of the butto...

Execute javascript in PHP

I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of <script> tags and javascript code that will substantially change the DOM after the load event. Is there a way to get the final HTML code directly from PHP, without opening the page with any browser? For example, let's say the HTML for the page is (it's just an...

HTML, Javascript function

I have a number of input fields that accept numbers. When the calculate button is pressed, the calculations are sent to a number of other input fields with the results. I then have to go and click each of the result fields to format the contents. I would like to be able to attach code to the calculation button, in order to format all th...

Javascript popup different size in different browsers?

How come this pop-up gets a size other than what I have specified, when testing it in IE6 and FireFox 3.6? Firefox displays it correctly but IE6 is smaller for some reason. (620x530 instead) How can I fix it? <A id="myID" onclick="window.open('/sitecollectiondocuments/myPage.htm',&#13;&#10;'welcome','width=630,height=590')" href="javasc...

How to tell if XUL menupopup opens down or up?

I have an extension that can be placed on any toolbar (like the bookmarks, menu or status bars). In general, the context menu opens downward, but when placed on the status bar and Firefox is closed to the bottom of the screen, the context menu opens upward. I'd like to try reordering the context menu based on its up or down orientation, ...

Post data to JsonP

Hi Is it possible to post data to JsonP? Or does all data have to be passed in the querystring as a GET request? I have alot of data that I need to send to the service, cross domain, and it is too large to send via the querystring What are the options for getting around this? thanks ...

Wordpress and Jquery slide

I am integrating a Jquery slider inside of wordpress here is the demo of the slider. I can see the div that is their but for some reason it is not showing up. View the working site here Now my problem is that this code: <script type="text/javascript"> var _siteRoot='index.php',_root='index.php';</script> <script type="text/javascrip...

JavaScript (jQuery) Regular Expression for searching through an array

First and foremost, I do not know RegEx but am trying to piece something together to make this work. Just wanted you to be forewarned. ;) Anyways, I'm trying to create a regular expression to take a word from an array and see if it matches a word in another array. I only want the search to return true if the keyword array string contain...

jQuery - script tags in the HTML are parsed out by jQuery and not executed

I have an HTML page like so: <html> <body> <div id='something'> ... <script> var x = 'hello world'; </script> ... </div> </body> </html> On another page, I am doing this: $.ajax({ url: 'example.html', type: 'GET', success: function(data) { $('#mydiv').html($(data).find('#something').html()); ...

User clicks link in email, it opens email client, how to close window/tab?

A user clicks a link in their HTML email, it then goes to a page that simply opens up their email client. window.location.href = 'mailto:...'; I don't want this window/tab to stay open, how can I close it? window.close() doesn't work since it wasn't opened using window.open() is it possible? ...

JScript: How to calculate difference between two date-times?

How can I calculate time difference in JScript between two times in milliseconds or seconds? For example, between 2010-04-23 15:03 and 2010-05-30 00:41 ...

jQuery: Is it possible to assign a DOM element to a variable for later use?

I'm working on a project that is using jQuery, which I'm much more familiar with Mootools. I'll start with my code first. var customNamespace = { status: 'closed', popup: $('#popup'), showPopup: function() { // ... } } $(document).ready(function(){ console.log($('#popup')); console.log(customNamespac...

DocumentFragment not appending in IE

I have a select list which, when changed, pulls data via ajax and dynamically creates select lists. Then based on the data used to create the select lists (a type), I pull more data via ajax if i don't have it already and create the options for the select list and store them in a fragment. Then I append that fragment to the select list...

Javascript Pointers question with Dates

I noticed this situation in my code (unfortunately), and was able to duplicate it in my own JS file. So I have this code: var date1 = new Date(); // today var date2 = date1; date2 = date2.setDate(date2.getDate() + 1); // what is date1? After this code executes, date1 is today's date + 1! This harkens back to my undergrad days when I...

How to disable text selection using jquery?

Does jquery or jquery-ui has such functionality? Disable text selection for given document element. ...

JavaScript function, which reads connections between objects

I have a JavaScript literal: var members = { "mother": { "name" : "Mary", "age" : "48", "connection": { "brother" : "sun" } }, "father": { "name" : "Bill", "age" : "50" }, "brother": { "name" : "Alex", "age" : "28" } } Than I have a fun...

javascript regex to extract a word from middle of 6 sentence

i have a string like following: Assigned to ram on 2010-04-22 12:30:13.0 i need to extract the third word (ram). I tried the below regex, its not working. /\s[a-zA-Z]*\s/ any help to fix this would be greatly appreciated. ...

JavaScript - Efficiently find all elements containing one of a large set of strings

I have a set of strings and I need to find all all of the occurrences in an HTML document. Where the string occurs is important because I need to handle each case differently: String is all or part of an attribute. e.g., the string is foo: <input value="foo"> -> Add class ATTR to the element. String is the full text of an element. e.g....

Jquery: How to target the parent ul and count the li's held?

I am using jstree to build a tree menu. When you select an item in the tree a div on the right brings up certain information. The information can be deleted. When it is deleted I remove that item from the tree. The problem is when the last li is removed from the ul, I need to remove the ul and also remove the "open" and "close" classes...

Pass variables to current tab via chrome extension

I am writing my first chrome extension, and I want to pass a variable to the currently opened tab and manipulate the DOM with it. My extension has a button, and when clicked, is executing this code: chrome.tabs.getSelected(null, function(tab) { chrome.tabs.executeScript(tab.id, { file: 'tabscript.js' }); }); This works fine, but ...