I would like to have page which uses a few xhr objects and automatically (after 30 seconds) starts the same few requests again It works for me well in IE7, IE8, but not IE6 (where is in browsing history chosen option "automatically" ). It works there only for first time and I can't set it for circular reloading. It looks like page is reloaded, but xhr objects are not doing their job ...only - as I wrote - for first time after page load.
I basically have several buttons that are created dynamically via a db, so I can have 1 to 40 etc. now at the moment I give each one a unique id and a hover code in the loops. see below:loops goes here..
I want a specific function to be available to multiple objects.In the script, if it says 'document.Form.Input.value' with 'Form' being the form name and 'Input' being a form element, how can I change this so that I can have two different forms with elements and the function will be able to work for both?
I was wondering if there is a way to simplify or clean up the code, since they are all doing the same thing and responding to the same event. This is just for refactoring reasons because my code is getting too long/messy.
I was wondering how you would list multiple variables after a equal ==? Example.... if ( pathname == schoolinformation, chaplainchatter) $('#button_newspress_archive,#button_tech_college,#button_parent_portal,#button_transition_portal,#button_6th_form,#button_connect,#button_vacancies,#button_vle_login').css('display', 'none'); $('#school_information_sub').css('display', 'block'); if ( pathname != schoolinformation, chaplainchatter) $('#school_information_sub').css('display', 'none');
Or even list multiple URL's within the variables? Example .... var schoolinformation = '/st-paul-s-website/school-information/school-news/headteachers-headlines', '/st-paul-s-website/school-information/school-news/chaplain-chatter-headlines';
I have this code <script type="text/javascript"> jQuery(document).ready(function(){ $("select").click(function(){ alert($(this).attr('id')); }); }); </script> <FORM><select name="category" id="#link1"> <option value=1>1</option> <option value=2>2</option> </select></FORM> <FORM><select name="category" id="#link2"> <option value=1>1</option> <option value=2>2</option> </select></FORM> <FORM><select name="category" id="#link3"> <option value=1>1</option> <option value=2>2</option> </select></FORM> When I click on any of the select fields, I always get 3 subsequent alerts, each with the id of the clicked select field. What I would like is to have only 1 alert with the clicked select id, whenever I click it.
I have a set of functions that will transition/fade photos in and out as background images. Easy. But now I would like to run the same functions on a different html page with different photos (each different page represents a different JavaScript array).
I've been reading online on how jQuery methods can be called into functions. So my thought process is to create 2 methods (1 for the original images and the 2nd method for the other images).
So here is my base code which works... $.landingpage = function() {
/*Enable background image cycles on landing page*/ var images=new Array('/image01.jpg','/image02.jpg'); var nextimage=0;
the situation: I'm building a web page, and the client wants to have three flash galleries on staggered timing (i.e., the first one loads and runs, 4 seconds later the second loads and runs, 4 seconds later, third one loads and runs).
I've been trying to figure out how to use Javascript to handle the initial delay between each object, and the best I can figure is to use an onLoad to start the first flash (Flash1), and then call out a function with setTimeout to start Flash2 4 seconds after Flash1 loads, and the same thing for Flash3. However, my attempts thus far have failed, and all three load up at the same time.
Is there a way in Javascript or Jquery to return an array of all objects underneath a certain point, ie. the mouse position. Basically, I have a series of images which link to various web pages but I have a large semi transparent image positioned over the top of the other images. I want to find the href of the background image that the mouse pointer clicks over.
I am trying to figure out how to use objects properties in my code so when the page loads All my properties are in object where I can use elsewhere in my page. Code:
I'm trying to use the following code to load xml files:
ImportXML = function (ts) { this.file = ts; if (document.implementation && document.implementation.createDocument) { this.doc = document.implementation.createDocument("", "", null); this.doc.obj = this; this.doc.onload = this.callBack; this.doc.load(this.file); } else if (window.ActiveXObject) { this.doc = new ActiveXObject("Microsoft.XMLDOM"); this.doc.onreadystatechange = this.ready; this.doc.obj = this; this.doc.load(this.file); } else { alert("Error"); } } ImportXML.prototype.ready = function () { if (myDoc[counter].readyState == 4) this.obj.callBack(); } ImportXML.prototype.callBack = function () { alert('loaded'); }
var xmlDoc = new ImportXML("bar.xml");
The problem I'm having is with the second line that reads this.doc.obj = this;
IE tells me that object doesn't support this property or method. How is it possible to get a reference to the object (xmlDoc) in the prototypes 'ready' and 'callBack" with IE?
I've been stumped. I'm usually good at figuring this stuff out, but I'm completely confounded here.I have a form with tables in it to add items to a series. The rows are being added dynamically by Jquery on the click event.
I am using jquery with the cookie plugin and I have multiple image buttons that can hide/show multiple elements. My question is how can I add a cookie to this code to remember whether each separate element is opened or closed?
The code, $(document).ready(function() { // choose text for the show/hide link - can contain HTML (e.g. an image) var showText='<div class="expanddown"></div>'; var hideText='<div class="expandup"></div>'; // initialise the visibility check var is_visible = false; // append show/hide links to the element directly preceding the element with a class of "toggle" $('.toggle').prev().append('<a href="#" class="togglelink">'+hideText+'</a>'); // capture clicks on the toggle links $('a.togglelink').click(function() { // switch visibility is_visible = !is_visible; // change the link depending on whether the element is shown or hidden $(this).html( (!is_visible) ? hideText : showText); // toggle the display - uncomment the next line for a basic "accordion" style //$('.toggle').hide();$('a.toggleLink').html(showText); $(this).parent().next('.toggle').slideToggle('fast'); // return false so any link destination is not followed return false; }); }); HTML, <a class="togglelink" href="#"></a> <div class="toggle"> Content </div>
I'm trying to search for the correct code to make my form work. I have 3 select boxes - one with 2 options, one with 8 options, and the last with 2 options... All of this adds up to 32 different url paths. Can anyone tell me how to get this done?This is what I have so far: (and yea, I know I suck... I honestly have absolutely NO clue)
This is my first post to this forum. When a button in parent window is clicked multiple times, more than one popup window is opened. This problem is occurring in linux firefox and mozilla browsers. In windows the code is working fine. Is there any option in window.open() method to open a popup window once. s there any known issue regarding this case?. Need a workaround to fix this issue.
hen a button in parent window is clicked multiple times, more than one child window is opened. This problem is occurring in linux. In windows the code is working fine. Is there any option in window.open() method to open a child window once.
If you have a javascript interpreter running in an environment unknown to you (as in what objects it exposes to the language) is it possible to loop through all objects in some way?
This is a non-browser environment, specifically the scripting engine for doing xslt extensions in msxml.
"When we combine FUNCTIONS with OBJECTS we get METHODS". Then he creates an empty ARRAY:
var a = [];
then he uses the "push() method" to add elements to the array.
a.push(1,2,3);
uh, methods are for *objects* right? Yet he is using them on an ARRAY.how an array can magically becomes an object that is manipulated by a "method"?I mean, the array is still an array, no? It never actually becomes an object, right? Yet we still use a *method* to manipulate it. See my conceptual quandry?
I've often write javascripts that use this rather common code to get all tags in an XHTML document:
var alltags = document.getElementsByTagName('*') ... and then use a for loop to access the elements as an array, for example: for (i=0;i<alltags.length;i++) { elementClass=alltags.className [i]Do stuff }
This has always seemed to work in the past, but I recently learned that the getElementsByTagName method returns a DOM NodeList, not an array. I'm currenly working on a project that needs to access the children of an element conditionally upon its class.
I have three questions. First: How do I declare a global variable to be a DOM NodeList object? It wouldn't be assigned until called from a function, so something akin to var elementList = document.getElementsByTagName() in my global declarations is out of the question. Is there something like var elementList = new NodeList() in javascript? (I know that I can assign it in a function without the var and it will be global, but other people may have to work with this code, and I'd like to have it clearly declared at the head of the program.)
Second question: Assuming alltags is a NodeList returned from a getElementsByTagName call, which of these is proper? This:
childElements = alltags[i].getChildNodes() ... or this: childElements = alltags.item(i).getChildNodes() And finally, which of the above techniques has better browser support?
I recently had a problem where I needed to build up an array of strings, that would be join()ed into a string when the array building was complete. however, each value could only be in the array once.
This was a problem for a few reasons. Once a value has gone into an array the only way to check for it that works cross-platform is to scan the array looking for the value. FireFox has the every() and some() functions but they don't work in anything else.
Using an object to simulate an assocaiative array would allow me to avoid this problem by storing key/values with the keys having the same value as the value I was storing. I could then use the (a in b) construct to check that I had not already added a value.
However, array type methods won't work with objects, so I had no access to size () or join () meaning I'd have to manually build the string by iterating over the object.
My solution was to use an array object, but to store the provided data i nboth the array proper and as a property of the array object.
var myArray = new Array;
function addVal (val) { if (!(val in myArray)) { myArray [val] = 1; myArray.push (val); } }
This approach does use up more memory but it does give me the advantages of both arrays and objects for little extra work. (if you don't have FireBug then replace console.log with alert)
That arrTD will have an array of "HTML DOM TableData Objects".
Now what is the best way to access each object and see what it contains. I would like see which properties each object has and what their values are. I also guess there could be some other objects within the TD object and maybe even some events and methods.
Now I have been reading an on-line reference about DOM, but I think it is a little dated.
http://www.w3schools.com/htmldom/default.asp
For example I know that a <TD> can contain class="something" but I could not find a property called class, but it did list others like id, align etc.
I would like to learn how to access and view the contents of a DOM object.