JavaScript - Not Detecting Window.onload From Child Pop-up Window
I am trying to pop up a window and then do stuff(set flags) when the content of the new window is done loading. For this I am trying to detect the window.onload of the pop-up child window but so far I am unsuccessful. I believe my problem is that the URL of child window is on different domain, than the one of the opener(parent) so that the window.onload is not being called. Thought this may change, at the moment I do not have access to the code for the page I'm opening up in the pop-up. Im pretty new to web development. Any help is appreciated.
Heres my js code Code: //globals var popupHandle = null; var openingWindow = false; function popWindow(URL){ var windowId="sameid"; if (openingWindow == true) { alert("Please wait, content is still loading") return; } if ((popupHandle == null || popupHandle.closed)){ //is first time run or window was closed openingWindow = true; popupHandle = window.open(URL, '" + windowId + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=900,height=500'); popupHandle.onload = function(){ //this is the code that never executes even if I all I put in here is simple alerting openingWindow = false; windowHandle.focus(); }; } else{// window still exists, reset attributes if (popupHandle != null) { popupHandle.location.href = URL; popupHandle.focus(); } } } Note: The whole reason why I am doing this is because if its the first time I am clicking on the button that will open this pop up window and I click it repeatedly very quickly, a new pop up is opened for each time I clicked eventhough the window.open is supposed to reuse the window if it has the same windowId. The first call to window.open takes long enough to not have a window handle ready and this allows other clicks to get through. Similar Tutorialsi have this code i need to close the parent.html window when the child window opened, i need the code for that working well in IE and Firefox Parent.html <HTML> <SCRIPT TYPE="text/javascript"> function sendTo() { window.open('child.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+''); } </SCRIPT> <BODY > <form name="form"> <input type="text" value="" name="text1" id="pdetails1"> <input type="text" value="" name="text1" id="pdetails2"> </br> <input type="submit" value="submit" onClick="sendTo()"> </BODY> </HTML> child.html <html> <body> <form> <input type=text name="text5" value=""> <input type=submit name="submit"value="submit"> </form> </body> </html> I have created and opened a child window called "checkwin" and have written some data to it. If the data is valid, I want the user to click on the 'CONFIRM' button on the child window, at which time I want the "submit()" function for the form on the parent window to be executed. If the data is invalid the user clicks on 'MODIFY' and I want focus to return to a field on the parent form. However, when I click on the "CONFIRM" or "MODIFY" buttons on the child window, nothing happens. Here is the code: Code: checkwin.document.write("</td></tr><tr><td align='right'><input type='button' value='CONFIRM' onclick='opener.document.personnel_form.submit()'></td><td></td><td><input type='button' value='MODIFY' onclick='opener.document.personnel_form.first_name.focus()'></td></tr></table>") Hi All, I need to show/focus the parent window which is in back when click a link from child window in Chrome.This problem is in Chrome browser only. We have used the below code self.blur(); Window.opener.focus(); But this is not working in Google Chrome. Please suggest me some workaround to achieve this. Thanks in Advance Reply With Quote 12-19-2014, 09:26 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts Window is not defined. window is. JavaScript (and the DOM) is case sensitive. You must pay attention to upper/lower case spelling, carefully. By the way, you shouldn't need the blur() call. If you focus on some window (any window) then any other focus should be lost. After following the instructions from the answer below: http://bytes.com/topic/javascript/an...arent-document I was able to have the child window perform the function defined in the parent window. The function was to only have an alert window pop up as the child page was loading. I easily modified this to my intention which was to have a parent function performed when the child window was clicked. Using the body tag: Code: <body onclick="parent.FUNCTION NAME HERE()"> I first change the method in which the function would be triggered, all went well there. then I tried to change which function would be triggered. (Basically use the function I wanted to happen on click of the child window rather then the function from the test). Once I did this switch, nothing happens. The site this is being used on is: http://tylerpanesar.ca/ What I want is when the menu bar is open in the parent window, the user chooses a link and the menu closes and goes to that link in the child window. This already works. However if the user opens the menu bar and then changes there mind and continues with the page the are currently on (clicks any content in the child window), the menu stays open. Currently the menu "hides" only when you choose one of the menu items, but it does not "hide" when you CLICK on child document. If you could figure out how to get it to "hide" on a "mouse out" that would be the better option. I attempted this method however i could only get it to "toggle" the menu on "mouse out". This method does however create an annoying flicker when you hover over the menu items (as it is toggling the open menu command I guess). If I had it "hide" the menu on "mouse out" it would "hide" as soon as you moved off of the main button. The viewer doesn't even have a chance to click a link. or at least that is what happens when I did it. You may have a better method to achieve this. The script that tells it to hide on click is within a jQuery function: Code: menua .click( function(){ menu.hide(); the code I used for the mouseout toggle was: Code: menu .mouseout( function(){ menu.toggle(); Here is the script that I am currently using for the menu to open and the "click" hide feature. This menu feature comes from the following help: http://www.bennadel.com/blog/1740-Bu...-FaceBook-.htm Code: <script type="text/javascript"> jQuery(function( $ ){ var menuRoot = $( "#menu-root" ); var menu = $( "#menu" ); var menua = $( "#menu a" ); // Hook up menu root click event. menuRoot .attr( "href", "javascript:void( 0 )" ) .click( function(){ // Toggle the menu display. menu.toggle(); // Blur the link to remove focus. menuRoot.blur(); // Cancel event (and its bubbling). return( false ); } ) ; menua .click( function(){ // Toggle the menu display. menu.hide(); } ) ; // Hook up a click handler on the document so that // we can hide the menu if it is not the target of // the mouse click. $( document ).click( function( event ){ // Check to see if this came from the menu. if ( menu.is( ":visible" ) && !$( event.target ).closest( "#menu" ).size() ){ // The click came outside the menu, so // close the menu. menu.hide(); } } ); }); </script> I've tried adding the click to "hide" menu feature to the child document but there is now menu in that document for it to "hide". What I was trying to was have the child document execute a function from the parent document and have that function executed IN the parent document. I've tried the technique from the link in my very first post but I believe it only calls the function from the parent and executes it IN the child. Which does not work for me as the menu is not in the child. There should be a way to make the child execute a function FOR the parent. I apologize for this very wordy post, but I am extremely frustrated with this now as I have been trying to get this to work for a few weeks now. Any help would be greatly appreciated. Thanks in advance, Tyler Hi, I am creating a new child air window called "test.html" as follow. How can I call a javascript function in parent window from child window? function createMyWindow() { var options = new air.NativeWindowInitOptions(); options.type = air.NativeWindowType.LIGHTWEIGHT; options.systemChrome = air.NativeWindowSystemChrome.NONE; options.transparent = true; mywindow = air.HTMLLoader.createRootWindow(false, options, false); mywindow.load(new air.URLRequest("test.html")); .... } Thanks, ASM For a parent window opened a child window, how can the parnet window be notified when the child window is closed or terminated? Thank you. Hi, I have parent page with 10 child window and i want to close all child window when click on close session button on parent but first i need to check whether any child window open or not after that action should be done for close the child window. +++++++++++++++++++first window+++++++++++++++++++++++++ <html> <head> <script language="javascript"> var myWindow; function christDoes(){ mydWindow=open("second.html", "yes"); } </script> </head> <body><form name="myform" method=POST ACTION="sake.html" ><CENTER> <B>ENTER YOUR SUBJECT</B><INPUT TYPE="TEXT" NAME="subject"> <input type="button" name="ok" value="OK" onClick="christDoes()"> </form> </body> </html> +++++++++++++++++++first window+++++++++++++++++++++++++ +++++++++++++++++++second window++++++++++++++++++++++ <html> <head> <script language="javascript"> function me(){ displayColor(); } function displayColor() { callWindow=window.open("third.html","fine"); } var m=0; var fSubject = self.opener.document.forms[0].subject.value; if(fSubject.length>0){ if(isNaN(fSubject)){fSubject="";} else{opener.alert("Please enter figure");} numSub=parseInt(fSubject); if(numSub==2){var strSub="ab";} self.document.write("<center>" +"ENTER SUBJECT HERE" +"</center><br>"); var mercy="<HTML><BODY>" mercy +="<FORM ACTION='save.html' METHOD='POST'>" mercy +="<CENTER>" sub=new Array(strSub.length); for(var i=0; i<sub.length; i++){ m++; mercy +=m +"<input type='text' name='sub[i].toLowerCase()'>" +"<BR>"; opener.alert("You have entered" +m +"subjects"); } } mercy +="</CENTER></FORM></BODY></HTML><BR></BR>"; self.document.write(mercy +"<BR>"); self.document.bgColor="pink"; self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT' onClick='window.open('third.html', '')'>" +"<center>"); } </script> </head> <body onload='me()'> </body> </html> ++++++++++++++++++++++second window++++++++++++++++++++ ++++++++++++++++++++++third window+++++++++++++++++++++ <html> <head> <script language="javascript"> function help(){ self.document.write("this is me") self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onLoad="help"> </body> </html> ++++++++++++++++++++++third window+++++++++++++++++++++ Can somebody help me with the code to make this button work? In the parent window when 2 is input in the text box and 'OK' button clicked, the second window opens with 2 text box and 'SUBMIT' button. If 'SUBMIT' button is clicked in the child window i want it to open the third window. Please help me out. Thanks. God bless in Jesus name. *ADDED* Though i am advised to add 'window .open' as one of the arguments to the OK button which i did yet it doesn't work somebody please help me out! I am using Mozilla 3.6 could this mean that it doesn't support this? +++++++++++++++++++++++++++first window+++++++++++++++++++++++++ <html> <head> <script language="javascript"> var myWindow; function christDoes(){ mydWindow=open("second.html", "yes"); } </script> </head> <body><form name="myform" method=POST ACTION="sake.html" ><CENTER> <B>ENTER YOUR SUBJECT</B><INPUT TYPE="TEXT" NAME="subject"> <input type="button" name="ok" value="OK" onClick="christDoes()"> </form> </body> </html> +++++++++++++++++++++++++++parent window+++++++++++++++++++++++++ ++++++++++++++++++++++++++++child window++++++++++++++++++++++ <html> <head> <script language="javascript"> function me(){ displayColor(); } function displayColor() { callWindow=window.open("third.html","fine"); } var m=0; var fSubject = self.opener.document.forms[0].subject.value; if(fSubject.length>0){ if(isNaN(fSubject)){fSubject="";} else{opener.alert("Please enter figure");} numSub=parseInt(fSubject); if(numSub==2){var strSub="ab";} self.document.write("<center>" +"ENTER SUBJECT HERE" +"</center><br>"); var mercy="<HTML><BODY>" mercy +="<FORM ACTION='save.html' METHOD='POST'>" mercy +="<CENTER>" sub=new Array(strSub.length); for(var i=0; i<sub.length; i++){ m++; mercy +=m +"<input type='text' name='sub[i].toLowerCase()'>" +"<BR>"; opener.alert("You have entered" +m +"subjects"); } } mercy +="</CENTER></FORM></BODY></HTML><BR></BR>"; self.document.write(mercy +"<BR>"); self.document.bgColor="pink"; self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onload='me()'> </body> </html> ++++++++++++++++++++++++++++++child window++++++++++++++++++++ +++++++++++++++++++++++++++++++new window+++++++++++++++++++++ <html> <head> <script language="javascript"> function help(){ self.document.write("this is me") self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onLoad="help"> </body> </html> +++++++++++++++++++++++++++++++new window+++++++++++++++++++++ Can somebody help me with the code to make this button work? In the parent window when 2 is input in the textbox and 'OK' button clicked, the second window opens with 2 textbox and 'SUBMIT' button. If 'SUBMIT' button is clicked in the child window i want it to open the new window. Please help me out. Thanks. God bless in Jesus name. Hi, I'm writing a page scraper in javascript which involves loading a page to scrape, detecting when the page has loaded successfully and then scraping the data. I can get the 'page loading detection' to work if I load the page in a sub-frame. But this is no good as some sites include frame-buster code which breaks my scraper and I cant get any of the framebuster-buster solutions to work. So instead I decided to look at loading the page in a separate tab. Does anyone know how to reliably detect when a page has finished loading in a tab please? I am using Firefox only and I dont mind if the solution requires some extension or greasemonkey script (I have already added the configuration/commands to allow access to pages from different domains). The code below shows an attempt. It sometimes detects when the initial page has loaded but when I press 'submit' it doesnt detect the second loading. Thanks. Code: <html> <head> <script type="text/javascript"> currentPageObj = window.open("http://www.bbc.co.uk", "currentPage"); currentPageObj.addEventListener("load", function(){alert("loaded")}, false); </script> </head> <body> <form action="http://www.example.com" rel="nofollow" target="currentPage"> <input type="submit"> </form> </body> </html> Hi, I am doing some work, where I want to have a table heading that remains in a fixed position, when the window is scrolled (I will ultimately have a very long table). I have written the code below, which fixes the heading. I am trying to make it so that each body row of the table gets hidden, when the window is scrolled such that the row passes above the heading row. To do this I need to somehow detect the distance of each row from the top of the window as the window is scrolled so I can detect when it goes above the fixed heading row. I have tried to do this using offsetTop and scrollTop in the code below, but it doesn't seem to be working (in Safari at least, which I am using for my main testing). Does anyone know a simple way of detecting the distance to the top of the window so I can use it in my code below, which will work in all browsers? (I don't really want to use div, and overflow-y:auto to achieve the fixed heading scrollable table, because I don't want to have a sub-section with its own scrollbar. I just want to have the main page scrollbar when the list gets long enough to require it.) Thanks for your help. Cheers, Laudrup Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>test simple scroller</title> <style type="text/css"> .myvisible { visibility:visible; } .myinvisible { visibility:hidden; } table#mytable td { border-color: black; border-width: 1px 1px 1px 1px; border-style: solid; } table#mytable th { border-color: black; border-width: 1px 1px 1px 1px; border-style: solid; } table#mytable thead { position:fixed; top:50px; background:white; z-index:+1; } </style> <script language="JavaScript"> <!-- Beginning of JavaScript - var rows; function hideoverflow() { rows = document.getElementById("mytable").getElementsByTagName("tr"); for (i=1; i<rows.length; i++){ if((rows[i].ScrollTop - rows[i].offsetTop)>50){ rows[i].className="myinvisible"; } else{ rows[i].className="myvisible"; } } } // - End of JavaScript - --> </script> </head> <body onScroll='hideoverflow();'> <p>My heading</p><br> <table id="mytable" border="0" cellspacing="0"bordercolor="black"> <thead> <tr> <th width="100" bgcolor="white">HeadA</th> <th width="140" bgcolor="white">HeadB</th> <th width="120" bgcolor="white">HeadC</th> </tr> </thead> <tbody> <tr> <td width="100">row1</td> <td width="140">row1</td> <td width="120">row1</td> </tr> <tr> <td>row2</td> <td>row2</td> <td>row2</td> </tr> <tr> <td>row3</td> <td>row3</td> <td>row3</td> </tr> <tr> <td>row4</td> <td>row4</td> <td>row4</td> </tr> <tr> <td>row5</td> <td>row5</td> <td>row5</td> </tr> <tr> <td>row6</td> <td>row6</td> <td>row6</td> </tr> <tr> <td>row7</td> <td>row7</td> <td>row7</td> </tr> <tr> <td>row8</td> <td>row8</td> <td>row8</td> </tr> <tr> <td>row9</td> <td>row9</td> <td>row9</td> </tr> <tr> <td>row10</td> <td>row10</td> <td>row10</td> </tr> <tr> <td>row11</td> <td>row11</td> <td>row11</td> </tr> <tr> <td>row12</td> <td>row12</td> <td>row12</td> </tr> <tr> <td>row13</td> <td>row13</td> <td>row13</td> </tr> <tr> <td>row14</td> <td>row14</td> <td>row14</td> </tr> <tr> <td>row15</td> <td>row15</td> <td>row15</td> </tr> <tr> <td>row16</td> <td>row16</td> <td>row16</td> </tr> <tr> <td>row17</td> <td>row17</td> <td>row17</td> </tr> <tr> <td>row18</td> <td>row18</td> <td>row18</td> </tr> </tbody> </table> </body> </html> Hi I am in need of some help with my Javascript code, basicly I am creating a Javascript SDK for my site and I am trying to make is a little like jQuery in which you check if the document is ready such as $('document').ready(function(){}); which my SDK looks like this $.functions.push(function(){}); the only thing is when using it like this each function push gets added to the functions array which i then need to use on the documents load. With my SDK I use $.onload.ready();, which should act as window.onload and run all the functions with-in the array but I cant seem to get it to work. This is what I currently have. Code: $.functions =new Array(); $.onload = {}; $.onload.ready = function(){ if(window.onload !== undefined && window.onload != '') { window.onload=function(){for(var i=0;i<$.functions.length;i++){$.functions[i];}}; } }; Can anyone help me out? Thank You DJCMBear EDIT: Don't worry I have found the solution and it works! This is the code for the onload. Code: $.onloadAdd = function(func) { if(typeof onload == 'function') { var oldonload = onload; onload = function() { oldonload(); func(); } } else { onload = func; } }; $.onload = function(){ if(window.onload !== undefined && window.onload != '') { for(var i=0;i<arguments.length;i++) { $.onloadAdd(arguments[i]); } } }; And this is the onload functions that get added to the list to be run. Code: $.onload(function(){if($.Class('Listener')){for(i=0;i<$.Class('Listener').length;i++){$.Class('Listener')[i].onclick=function(){alert($.getInfo(this).innerHTML);};}}},function(){if($.Class('Add')){for(i=0;i<$.Class('Add').length;i++){$.Class('Add')[i].innerHTML=$.Class('Add')[i].innerHTML+'...';}}}); Hi everyone, I am at the last leg of getting my code to run. I have a window.onload function, but right now it is working only when I fill in all the field in the drop down list, hit a refresh and then hit submit button. What changes should I implement in the code? The code after the window.onload function runs as follows: Code: window.onload = function() { age = 0; groom_age = getvalues(); caste = 0; groom_caste = getvalues_1(); profession = 0; groom_profession = getvalues_2(); bachelor = 0; groom_bachelor = getvalues_3(); master = 0; groom_master = getvalues_4(); doc = 0; groom_doc = getvalues_5(); country = 0; groom_country = getvalues_6(); color = 0; groom_color = getvalues_7(); height = 0; groom_height = getvalues_8(); marriage = 0; groom_marriage = getvalues_9(); father = 0; groom_father = getvalues_10(); switch(groom_age) { case "23" : age = 1.6; break; case "24" : age = 1.2; break; case "25" : age = 1.7; break; case "26" : age = 1.8; break; case "27" : age = 1.9; break; case "28" : age = 1.75; break; case "29" : age = 1.7; break; case "30" : age = 1.4; break; case "31-35" : age = 1.8; break; case "36-40" : age = 1.9; break; case "41-45" : age = 1.75; break; case "46-50" : age = 1.7; break; case "51+" : age = 1.4; break; default: age = 1; } switch(groom_caste) { case "Brahmin" : caste = 1.6; break; case "Bania" : caste = 1.2; break; case "Kayastha" : caste = 1.6; break; case "Kshatriya" : caste = 2.0; break; case "Dalit" : caste = 1.8; break; case "Maravar" : caste = 1.6; break; case "Mudaliar" : caste = 2.0; break; case "Jat" : caste = 1.8; break; case "Labanas" : caste = 1.6; break; case "Rajput" : caste = 1.6; break; default : caste = 1; } switch(groom_profession) { case "Engineer" : profession = 1.6; break; case "Doctor" : profession = 1.2; break; case "Lawyer" : profession = 1.65; break; case "CA" : profession = 1.7; break; case "IAS" : profession = 2.0; break; case "Family Business" : profession = 1.5; break; case "Engineer + MBA" : profession = 1.95; break; case "None of the above" : profession = 1.95; break; default: profession = 1; } switch(groom_bachelor) { case "BTech/BE/BS" : bachelor = 1.6; break; case "MBBS" : bachelor = 1.2; break; case "BA" : bachelor = 1.1; break; case "B.Com" : bachelor = 1.4; break; case "BSc" : bachelor = 1.9; break; case "BBA" : bachelor = 1.1; break; case "Diploma" : bachelor = 1.4; break; case "Certification Course" : bachelor = 1.4; break; default: bachelor = 1; } switch(groom_master) { case "MS" : master = 1.6; break; case "MBA" : master = 1.2; break; case "MHA" : master = 1.4; break; case "MTech" : master = 1.4; break; case "M.Ed" : master = 1.4; break; case "No Master degree" : master = 1.4; break; default: master = 1; } switch(groom_doc) { case "Doctor of Philosophy (Phd)" : doc = 1.6; break; case "Doctor of Medicine (MD)" : doc = 1.2; break; case "No Doctorate Degree" : doc = 1.4; break; default: doc = 1; } switch(groom_country) { case "India" : country = 1.6; break; case "USA" : country = 1.2; break; case "Any European Country" : country = 1.7; break; case "Australia" : country = 1.7; break; case "Canada" : country = 1.7; break; case "Any Country more developed than India" : country = 1.7; break; case "Any Country less developed than India" : country = 1.2; break; default: country = 1; } switch(groom_color) { case "Fairy White" : color = 1.6; break; case "Black" : color= 1.2; break; case "Wheatish (Almost White. Would need some Fair n Lovely)" : color= 1.4; break; case "Brown": color= 1.4; break; case "White": color= 1.9; break; case "Pitch Black (Not visible on a moonless night)" : color= 0.6; break; default: color = 1; } switch(groom_height) { case 'Less than 5\'4"' : height = 1.6; break; case '5\'4"' : height = 1.2; break; case '5\'5"' : height = 0.8; break; case '5\'6"' : height = 1.0; break; case '5\'7"' : height = 1.4; break; case '5\'8"' : height = 1.5; break; case '5\'9"' : height = 1.6; break; case '5\'10"' : height = 1.7; break; case '5\'11"' : height = 1.8; break; case '6' : height = 1.85; break; case '6\'1"' : height = 1.9; break; case 'Greater than 6\'1"' : height = 1.8; break; default: height = 1; } switch(groom_marriage) { case "0" : marriage = 1.6; break; case "1" : marriage = 1.2; break; case "2" : marriage = 0.4; break; case "More than 2" : marriage = 0.2; break; default: marriage = 1; } switch(groom_father) { case "Doctor" : father= 1.6; break; case "IAS" : father = 1.2; break; case "Engineer" : father= 1.7; break; case "Lawyer" : father= 1.65; break; case "CA" : father= 1.8; break; case "Engineer + MBA" : father= 1.9; break; case "Family Business" : father= 1.2; break; default : father = 1; } }; function processOrder() { var total = age + caste + bachelor + master + doc + color + profession + father + marriage + height + country; var pageNumber = Math.floor((20 - total) / 2 + 1); // pageNumber = 6; // alert(pageNumber); window.open ("Page " + pageNumber + ".html"); } </script> <center> <INPUT TYPE="button" VALUE="Calculate" onClick="processOrder()"> </center> I would really appreciate any kind of help. Thanks a lot! while decomplicating things I putted into single jsp code like that: Code: <script language="javascript" src="../js/A.js" type="text/javascript"> </script> <script language="javascript" src="../js/B.js" type="text/javascript"> </script> The prob here is that both A and B contains window.onload, and only the one from A gets executed. All things that come to my mind is back to complications, loosing track of things. Any advice ? Hei, On my website , I have certain things that happen in the function window.onload. I need them to happen only the first time when the user acceses the page . Do you have any idea how to do this? Thanks Hi all can someone guide me (total JS newbie) on this presumably pretty easy task? I have a "parent" page with some text inputs in it (a form). This is what I am after: -when the user clicks a link it pops open a new window via JS - "child" (this is working). -in the "child" window there are also some text inputs (another form) (done). -when the user changes the value for 'testChild_textInput_4' in the child window, then I want it to automatically set this same value, to effectively overwrite, what is currently in 'testParent_textInput_2' in the parent window. Presumably this involves an onChange event, but it is also OK with me if the needful (the text input's value in the parent window being overwritten) happens upon the child window's form submit. If anyone can show me either trick, I would be thrilled! I set up a test page to make this all easy to talk about: http://www.yellow-turtle.com/testDumpMe_parent.html Please let me know! Thanks! -John The site i am building uses a large content slider as its main navigation. There is an absolutely positioned header on the page, and the slider sits underneath. This all works perfectly once i am linking (to named anchors) within the same page However when an external pages links to one of the anchors, the top of the slider content is hidden underneath the header - the user need to scroll down to get the content to start below the header. Long story short, I have used the following to force the browser to scroll to the top of the page when it loads: <script type="text/javascript"> window.onload = function(){ window.scrollTo(0,0); } </script> This doesnt load until everything else on the page has loaded though, is there a way to force the browser to scroll to the top BEFORE everything else loads? Or better yet not to scroll at all but to make sure the window is positioned at (0,0) automatically when it loads? Also, this doesnt seem to be working at all in IE Thanks in advance! Hi, I am learning Javascript and place the script tag in the head of my document and the code doesnt work as it loads the page. I understand that the window.onload function must call the function when the page has loaded but i cant seem to get it to work, I have wrapped my changeImage function in the onload function and it still doesnt work. where am i going wrong? I would like the script tag in the head of the document and understand how to use the window.onload function with my changeImage function. Thank you. Code: window.onload = function () { changeImage(); } var myImage = document.getElementById("image"); var imageArray = ["images/leaf.jpg","images/sky.jpg","images/tree.jpg"]; var imageIndex = 0; function changeImage() { myImage.setAttribute("src", imageArray[imageIndex]); imageIndex++; if (imageIndex >= imageArray.length) { imageIndex = 0; } }// changeImage ... end setInterval(changeImage, 3000); I wrapped the whole of the code in the function but then in the console it doesnt do the setInterval it just stops at that break point. I am something of a javascript noob - I write mostly PHP and don't do a lot in javascript. Anyway, I Googled what I wanted to do and found an example that uses window.onload = function() { ... whatever ... } which seems to work fine, but the brower's error console tells me that the use of captureEvents (which I presume includes window.onload()) is deprecated and that I should use addEventListener instead. I've had a look on google for examples of addEventListener for the equivalent of document.onload and although I understand the difference and I see how both mechanisms work, I'm struggling to understand why one is better than the other? Please enlighten me! Hello, I have a bit of javascript that automatically loads Shadowbox on load. It works perfectly in Firefox, Chrome but NOT IE. If I put a standard link to open Shadowbox does work in IE, so it's not the shadowbox, it's definitely the window.onload bit which isn't working. Here is my code. Code: <link rel="stylesheet" type="text/css" href="shadowbox/shadowbox.css"> <script type="text/javascript" src="shadowbox/shadowbox.js"></script> <!--this bit is for a link to open the Shadowbox from a link elsewhere on the page --> <script type="text/javascript"> Shadowbox.init({players:['swf']}); </script> <script type="text/javascript"> window.onload = function() { Shadowbox.open({ content: 'flash/flash002.swf', player: "swf", title: 'Open Shadowbox', width: 1200, height: 800, }); }; </script> This DOES work though, so I know it's not the Shadowbox with the issue Code: <a href="flash/flash002.swf" rel="shadowbox;height=800px;width=1200px">Open Shadowbox</a> Really appreciate your help! Nicola |