Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Posts posted by jesh

  1. I was wondering, does anybody know if the onload event will fire when you click an anchor in the same page?
    The load event fires when the document loads in the browser. If your page is called "index.html" and you have a hyperlink on that page that references "index.html", then, yes, when you click on that link, the page will reload, and the load even will fire.
  2. Check out the javascript reference regarding the Date object:http://www.w3schools.com/jsref/jsref_obj_date.aspYou can easily get the UTC (GMT) time like so:

    var date = new Date();document.write(date.toGMTString());// document.write(date.toUTCString());

    You can also use the getTimezoneOffset() method to figure out how many hours difference the client's computer is from GMT:

    var date = new Date();var timeDifference = date.getTimezoneOffset();

  3. You might try something like this:

    var box = document.getElementById("box");box.removeChild(box.lastChild);

    Check out the XML DOM tutorial as well. While the HTML DOM tutorial does a great job talking about the different methods and properties available to various HTML elements, the XML DOM does a great job talking about how to manipulate (e.g. add nodes, traverse nodes, remove nodes, etc.) the DOM.Another way, which may be a little more simple, would be to use the innerHTML property instead:

    function roll1(){ document.roll1p.src ="3.png";document.getElementById("box").innerHTML = "this is a test";}

    Then, to remove the text:

    document.getElementById("box").innerHTML = "";

  4. This function works for me, you might try it:

    function GetXmlHttpObject(){	var object = false;		if(window.XMLHttpRequest)	{		object = new XMLHttpRequest();	}	else if(window.ActiveXObject)	{		try		{			object = new ActiveXObject("Msxml2.XMLHTTP");		}		catch(e)		{			try			{				object = new ActiveXObject("Microsoft.XMLHTTP");			}			catch(e)			{			}		}	}		return object;}

  5. There are three distinct variables in your code named "xmlHttp".1) the global xmlHttp variable declared on the first line of code.2) the local variable inside your startup() function.3) the local variable inside your GetXmlHttpObject() function.What's happening is that you declare a variable called xmlHttp (1) and then, at some point, startup() fires. This function creates a new xmlHttp variable (2) and instantiates that variable as an XMLHttp object. The function also sets up the readystatechange handler called stateChanged(). When stateChanged() fires, it is referencing that global xmlHttp variable (1) that has never been instantiated. Hence, "xmlHttp is not an object".Try this instead:

    var xmlHttp;function startup(){	xmlHttp = GetXmlHttpObject();	...

  6. In any case, the safest reply is to ask them to clarify what they mean rather than guessing - you always want to make sure you are thinking about the same thing they are, especially in an interview or pre-screening meeting/calls.
    I think this is the best advice. If you aren't sure what an interviewer is talking about, ask that person to clarify. If I were hiring someone, I would rather the interviewee ask me what my question meant rather than spout out some answer that may have nothing to do with what I'm asking.
  7. That file may simply be corrupt on your computer at home. If you can open the file on other computers, try copying the file and emailing it to yourself. Then, when you get home, you can delete the file on your home computer and download the new version from your email. If it was a corrupt file, your problems should be solved.

  8. Alright, I'm back again. I gotta learn not to post here until after I've spent an hour or two searching...jeez.Found the solution here: http://forums.asp.net/thread/1406703.aspxYou have to dynamically create the event and fire it:

    if(document.createEvent){	var onchangeEvent = document.createEvent("HtmlEvents");	onchangeEvent.initEvent("change", true, false);	document.getElementById("test").dispatchEvent(onchangeEvent);}else if(document.createEventObject){	document.getElementById("test").fireEvent('onchange');}

    Seems like a kludge, but it works for me on IE6, Firefox (PC and Mac), and Safari. Anyone seen any better solutions?

  9. Hmm, just saw on a Google search that I need to call the onchange function when I programmatically change a value to get the onchange event handlers to fire.

    window.opener.document.getElementById("test").onchange();

    This, however, doesn't pass the DOM Event to that function. Any other ideas?

  10. Say you have the following page:

    <html><head><script type="text/javascript">function openwindow(){	var wnd = window.open();	wnd.document.open();	wnd.document.write("<html><body><scri" + "pt>");	wnd.document.write("window.opener.document.getElementById('test').value='New Value';");	wnd.document.write("</scri" + "pt></body></html>");	wnd.document.close();	wnd.close();}</script></head><body><input type="text" id="test" onchange="alert('changed!');" /><button onclick="openwindow();">Open Window</button></body></html>

    If you type text into the text box and change the focus to something else (e.g. click on the body somewhere), the onchange event for the text box will fire and "changed" will be alerted. However, if you click the button to run the javascript, a new window will be opened which will run some javascript to change the value of the text box to "New Value", the onchange event will not fire and there will be no alert.Is it possible to change the value of the text box from a child window and have the onchange event fire? Can anyone help explain to me why the event isn't firing in the element on the parent window when the change is originating from the child window?

  11. I belive there is a reson for learning VBscript, because it is not at all disimailar to VBA (al though I keep banging on about this, and VBA is much more capable) and, for people like me who know VBA, is a good way of heading towards learning JavaScript. It certainly helpded me.
    OK, I'll agree with that. The first language (after BASIC) that I learned was VBScript so that I could learn VBA (this was 1998) in order to work on a project for my employer at the time. This knowledge did help me better understand how javascript worked. Then, through javascript, I learned more valuable languages such as Java and C#.In my person experience, I would suggest that you completely ignore VB, VBA, and VBScript and dive straight into javascript. If you want to move on to a more powerful language, learn C#. Once you know javascript and either Java, C/C++ or C#, it'll be relatively easy to learn VB (VBScript, VBA, etc.) if you require it for a certain project.
  12. for(listed=0;listed>-1;listed++) {	 // Code to show each time listed is added to.}

    Just so you know, that loop will continue forever until you either return or break out of it or you explicitly set "listed" to some value less than or equal to -1.The loop says "Starting at 0, increment 'listed' by 1 as long as it is greater than -1". Which is to say, "loop forever".
  13. Absolute positioning pulls (for lack of a better term) the element out of structure of the page and treats it similar to the way a float works. Absolutely positioned elements are positioned relative to the nearest containing element that has positioning set. If no container if found with positioning, it would be positioned relative to the body.Relative positioning moves the element relative to where it would normally appear in the structure of the page.e.g.:

    <style>.outer { position:relative; top:50px; left:50px; background-color: red; }.inner { position:absolute; top: 0px; left: 0px; background-color: green; }</style><div class="outer"><div class="inner">test</div>some random content</div>

  14. I have seen quite a few site's that log you out after a time of inactivity.Maybe this is a nooby question but how do they do that ?
    You can use a cookie that expires. Then, the next time a request is sent to the server the server will check to see if there is a cookie in the request. If the cookie had expired, you could send the visitor to a login page (or a session expired page). And, to keep an active session active, on any page that required the user to be logged in, you could update the expire date for the cookie.
  15. Okay, the text file DOES already exist so i assume this is the problem. How can I make ASP overwrite the existing text file? I want to be able to let the user make changes to the existing text file. how do i do this? thanks.
    Check out this page for information on how to use CreateTextFile to allow it to overwrite existing files:http://www.w3schools.com/asp/met_createtex..._filesystem.aspHowever, you're probably better off using OpenTextFile to attempt to open the file. There is an optional parameter in that function that will create the file if it doesn't already exist.http://www.w3schools.com/asp/met_opentextfile.asp
×
×
  • Create New...