JavaScript - How Do I Close A Write?
Within my Flex application I write stuff to the browser via a javascript document write. Is there a command to send to indicate I want to close that stream?
When I send the command the rotating indicator keeps running indicating the browser is still expecting some stuff. If I click the stop button on the browser it stops spinning and the stuff I sent (an xml stream) becomes available. As this is an automated process, there is no person to hit the stop button. Similar TutorialsHi! I'm new to this, so please bare with me. My terminology may not be up to par. Here's the deal: - I have a button on my Flash site that opens an HTML page in a popup window. In Flash, I open the new window using Actiosnscript 2.0: Code: on (release) { getURL("example1.html", "_blank"); } - Within the popup window are links to other HTML pages. They all open in the same window. I've been using the following to create the links in Dreamweaver: Code: onClick="MM_goToURL('parent','example2.html')" - On each page, I have a "Return to Main Menu" button that should close the popup window. To do this, I have been using: Code: onClick="window.close()" - The problem is that it works differently in each browser, and I can't even get it to consistently close the window in most browsers: Internet Explorer = popup message appears, asking "Are you sure you want to close this window?" or something similar; window closes after clicking "Yes." Safari = Only closes if I'm on the original HTML page. If I click on any of the other links (note that these all open in the same window), those pages' "Return to Main Menu" buttons cease to work. However, if I keep clicking "Back" until I get to the original page, it closes. Opera = Button actually works for each page. Firefox & Chrome = Does not close the window at all. I looked into it and saw that others have used a window.opener to solve similar issues. But, since my popup window is opened using Flash/AS2, I need to find a way around it. I've tried preceding "window.close()" with "window.opener=null" (i.e. - onClick="window.opener=null; window.close()"), but I don't think I'm doing it right because it still doesn't work. I've also seen others use codes that involve functions and variables, but it is beyond my current coding knowledge to implement this. Like I said, I'm sort of new at this. Any advice would be greatly appreciated. Thank you. - PW I'm working on a website that will basically embed a widget/frame sent by a handler into a user's current page. The user basically adds a script tag to where they would like the HTML to be. The script tag has their settings and is basically a document.write that calls all the code that we want displayed. So here's my problem. We have a map that we need to add in a specific section, and to get the map we have to call another script tag. So we end up having a script tag (map) embedded in another script tag (the code for the widget/frame) or we end up having to document.write inside a document.write. Now this works just fine and as expected in Firefox, Safari, and Chrome. However, Internet Explorer and Opera wait until the first document.write is completely finished before calling the embedded one. Of course the problem with this, is that it takes the map out of the document's flow and just appends it to the bottom left of the page. Since the rest of the page has already been called, there's no way to move the interior "map" script. Any ideas? Basically just trying to figure out how (if even possible) to render an embedded script tag in Internet Explorer and be able to place it properly. I've tried everything that I can think of, including AJAX and Google's unescape script. Any suggestions, I'd greatly appreciate it. Or even if you've encountered a similar problem, and know that it just isn't possible in IE or Opera, that would be fine too. Thanks in advance! Hi i have a function (i wont write it out coz it is too long!) but after i have done the main calculations within this function i wont to display some of the variables in a table. i have writen: document.write( <table border="1"> <tr><td> Value 1 </td><td> document.write(a); //here * </td></tr> </table> ); were it says "here *" i wont to write within the table variable a (which i have defined properly in the function). However, as i have already written document.write it actually displays the text "document.write(a);" instead of the value for var a. Help asap please as it in for school soon! Thanks in advanced :D ok, so i got some help on here to modify some java that resides in a server-side program that is limited in scope of modification, but i was able to find the code that i need to modify to perform the behavior i need. the code below works great at making sure the user entry data is formatted correctly, but fails on 2 critical points: 1) it allows a blank entry (needs to give similar error message as when formatted incorrectly - see code) 2) it allows any formatting if a combination of alpha and numeric characters are used (needs to give error message if ANY alpha characters are used). THANKS so much in advance. Code: if( ! Form1.elements['EIF2'].disabled ) var n=Form1.elements['EIF2'].value.match(/\d/g).join(''); Form1.elements['EIF2'].value= [n.substring(0,4),n.substring(4,9),n.substring(9)].join('-'); { var re = /^\d{4}\-?\d{5}\-?\d{6}$/ if ( ! re.test( Form1.elements['EIF2'].value ) ) { alert( 'Lawson # must be 15 digits\r(Example: 1234-12345-123456)' ); return false; } } how to close a tab in html or javascript
I am having a heck of a time closing this popup window when i logoff the site. i open it by Code: shoutwindow = window.open("<?=$MY_LINK_ROOT?>/shoutbox/minichat.php", "shoutwindow", "location=0,status=0,scrollbars=0,menubar=0,resizable=0 width=300,height=310"); when i click logoff the site i want the popup to close also here is the logoff php Code: session_start(); //only for testing will remove this if(!shoutwindow.closed) { echo "window open"; self.close(); //shoutwindow.close (); // also tried both these didnt work // window.close(); } else { echo "Window already closed"; } mysql_close($link); unset($_SESSION['Sess_UserId']); // Unset all of the session variables. session_unset(); // Finally, destroy the session. session_destroy(); echo "<script> location.href='$MY_LINK_ROOT'</script>"; exit; ?> what am i missing here lol ? thanks UPDATE: i just had an idea, can i mix a href and an onClick together so that both are executed like this (i never tried it before) Code: the reason i use self.close is because i heard that it always closes the child not the parent. <a href="logoff.php" onClick="self.close()" return:true;>Log Off</a> the return true will make it execute the href as well right? Have been trying to make a button to close a web page but every time i try to get it validated "strict" it fails. I have used the following code. Code: <form action=""> <input type="button" value="Close Window" onclick="window.close()"> </form> Would really appreciate any help. Thanks I am trying to execute a simple window.close function to be used in IE8 and IE9, and window.close() doesn't seem to be working. Are there any known fixes?
this is quite embarrasing as i've done it before, but oh well... trying to close a window that is opened with a built-in dreamweaver function called MM_openBrWindow(). trying to use this code: PHP Code: if ($OutsideVisitors == "false") { echo '<center><strong><em><font size="4">THERE HAVE BEEN NO VISITORS TO THE WEBSITE TODAY... </font></em></strong><br><br><input name="closeme" type="button" id="closeme" value="Close Window" onclick="Window.Close()"; /></center>'; } i have also tried: PHP Code: onclick=javascript:Window.Close() it's just not behaving for me. any hints anyone? thanks a bunch! (the BrWindow() function in DW does open a popup window, so I think the js close() should work. if i remember right, a popup window is a prereq for that function to even work...) Hi! I have a problem with the function close(); The window does open but then it immediately closes by itself. I didn't even get to see the content and of course I didn't even click on the button "close the window!" I want to be able to see the content of the page and when I click on the button, it will close the window. Thank you in advance for your help! Code: var window; function newWindow(){ window=window.open("", "Results", "width=400, height=250"); window.document.write("<body><table>"); window.document.write("<h1 style='border-bottom-style: dotted; border-bottom-width: 1px;font: italic 16pt Times New Roman, sans-serif; color: navy;'>Survey's Results</h1>"); for(var i=0; i<tabVotes.length; i++){ window.document.writeln("<tr>"); window.document.writeln("<td style='text-align: center'>" + tabPeople[i] + "</td>"); window.document.writeln("<td style='text-align: center'>" + tabVotes[i] + " votes </td>"); window.document.writeln("</tr>"); } window.document.writeln("</table>"); window.document.writeln("<input name='Close' type='button' value='Close the window' />"); window.document.getElementById('Close').onclick = window.close(); window.document.writeln("<br /><br />Thank you!"); window.document.writeln("</body>"); } I have this script to close a div when I click outside of it. It works in Firefox but in IE7 i get an error: 'divid' is undefined. mydiv is the div I want to close and clickclick is the link that makes the div appear. Code: <script type="text/javascript"> function monitorClick(e){ var evt = (e)?e:event; var theElem = (evt.srcElement)?evt.srcElement:evt.target; while(theElem!=null){ if(theElem.id == "mydiv" || theElem.id == "clickclick" && document.getElementById(divid).style.display == 'none') { document.getElementById('mydiv').style.display = 'block'; return true; } theElem = theElem.offsetParent; } document.getElementById('mydiv').style.display = 'none'; return true; } document.onclick = monitorClick; </script> What should I change to make it work in IE7? I have a page with categories of images. When clicked, each image on the left opens a div with it's own gallery of thumbnails. http://myspringslandscaping.com/portfolio.html Right now, to close a div, the category image has to be clicked a second time. How can I set it so that when one div opens, the other closes automatically? The client wants only one category displayed at a time. Any help would be appreciated. Thanks! Marita I am working on my homework. On my page, I need to make a modal window, which is just a picture has x or close letter, shows up whenever people open the page. So far, I called a picture with onload in a body and centered the picture. I don't know if there is anyway that I can just put x or close somewhere so that whenever people click x or close, the picture is not going to be visible ( promoPic.style.visibility = "hidden" this is my code for the picture. And I though I can just put input button or any letters inside of picture because its wrapped by paragraph, but, I can't. I guess I am miss understanding some concept? Code: <body onload="promoCenter()"><p><img src="http://codingforums.com/images/hauntedHouse.jpg" id="promoPic" alt="Haunted House" height="400" width="400" /></p> Can someone tell me how to make a close button for this? The close button I currently have here makes the IMAGE2 disappear but I cannot see IMAGE1 until the time runs out on the setTmeout. I want to be able to click the closeX and close out the whole script leaving IMAGE1 showing. Here is what I have: Code: <table border="0" width="650" id="table1" cellspacing="0" cellpadding="0" bgcolor="#000000" height="350"> <tr> <td align="center"> <script type="text/javascript"> window.onload = function () { setTimeout(function () { var div = document.getElementById('hideOverlay'); div.innerHTML = 'IMAGE1 GOES HERE'; }, 6000);} </script> <div id="hideOverlay"> <table border="0" width="650" id="table1" cellspacing="0" cellpadding="0" height="350"> <tr> <td align="center" width="650" height="350"><a style="text-decoration: none" href="javascript:void(0)" onclick="var lyr =document.getElementById('hideOverlay'); lyr.innerHTML='';"/><font color="#666666" size="2">Close [x]</font></a>IMAGE2 GOES HERE</td> </tr> </table></div> </td> </tr> </table> </div> below code is not working for IE7. function closeWindowFun(e){ winX = navigator.appName=="Microsoft Internet Explorer" ? window.event.clientX : event.screenX; winY =navigator.appName=="Microsoft Internet Explorer" ? window.event.clientY :event.screenY; temp=navigator.appVersion.split("MSIE"); version=parseFloat(temp[1]); alert(version); closeFlg=false; if(version>=7){ if ((window.event.clientY < 0 && (window.event.clientY >-20 || window.event.clientY <-100)) && (window.event.clientX > (document.documentElement.clientWidth - 5) || window.event.clientX < 15) ){ loseFlg=true; } } else{ if(winX<0 && winY<0){ closeFlg=true; } } if(closeFlg){ window.opener.location .reload(); window.close(); } } please give me suggestions I've been trying to write a script that activates a confirm box when a browser window is closed. I want this to occur only when they try to close the window, not if they click on links on the page to navigate elsewhere. The confirm box then gives the option to continue closing as they intended or, if they click on ok (or cancel if it's easier), navigate to another page I specify. The script below works but it displays a confirm box when you close the window and click on links. Code: <script type="text/javascript"> function show_confirm() { var r=confirm("Wait! Would you like check out yahoo?"); if (r==true) { window.open("http://www.yahoo.com"); } else { window.close(); } } window.onbeforeunload = show_confirm; </script> I understand you may be able to create a variable that you then attach to any links on the page you don't want to activate the confirm box. I don't know how to do this. Thank you. I have a div with an icon and some text. When the user hovers over the area, a box appears above it with a few links in the box. I want the user to be able to select any of these links, as well as have the option NOT to select these links and have the box disappear when he moves off of the box. I can't seem to achieve this with the script I'm using now - right now, as soon as the user moves off of the div/icon and moves the cursor UP to select the links in the box, the box disappears. Any ideas? Here's my JS code: Code: <script language="JavaScript"> function show_it(){ document.all.box1.style.visibility = "visible"; } function hide_it(){ document.all.box1.style.visibility = "collapse"; } </script> Here's my CSS code: Code: #box1{ position: absolute; top: -186px; left: 147px; visibility: hidden; } #socialmedia-action-items-container {position: relative; float: right;} #box-wrapper {padding: 0 0 21px 0; height: auto; width: 160px; background: url(../images/socialmedia/sm-funnel.png) 10px bottom no-repeat; float: left;} #box-main {padding: 10px 10px 0 10px; height: auto; width: 140px; background-color: #cc0000; float: left;} a.box-item1 { /*flickr*/ padding: 5px 0 10px 45px; height: 36px; width: 100%; color: #fff; background: url(../images/socialmedia/flickr.png) top left no-repeat; float: left; font-size: 1.3em; line-height: 0.8em;} a.box-item1:hover { color: #000; background: url(../images/socialmedia/flickr-over.png) top left no-repeat;} a.box-item1 span {font-size: 0.7em;} a.box-item2 { /*facebook*/ padding: 5px 0 10px 45px; height: 36px; width: 100%; color: #fff; background: url(../images/socialmedia/facebook.png) top left no-repeat; float: left; font-size: 1.3em; line-height: 0.8em;} a.box-item2:hover { color: #000; background: url(../images/socialmedia/facebook-over.png) top left no-repeat;} a.box-item2 span {font-size: 0.7em;} a.box-item3 { /*twitter*/ padding: 5px 0 10px 45px; height: 36px; width: 100%; color: #fff; background: url(../images/socialmedia/twitter.png) top left no-repeat; float: left; font-size: 1.3em; line-height: 0.8em;} a.box-item3:hover { color: #000; background: url(../images/socialmedia/twitter-over.png) top left no-repeat;} a.box-item3 span {font-size: 0.7em;} Here's my HTML code: Code: <div id="socialmedia-action-items-container"> <a class="twitter" onMouseOver="show_it()" onMouseOut="hide_it()"> <span class="twitter-first">Follow Us on</span><br /> <span class="twitter-last">Twitter</span> </a> <div id="box1"> <div id="box-wrapper"> <div id="box-main"> <a href="#" class="box-item1">Follow us <br /><span>on Flickr</span></a> <a href="#" class="box-item2">Follow us <br /><span>on Facebook</span></a> <a href="#" class="box-item3">Follow us <br /><span>on Twitter</span></a> </div> </div> </div> </div> Much appreciated! Been trying for three days to find a way to self close a FF window. The window is opened from a link on a board, and its only purpose is to run an onLoad script that launches a popup window, after which I need it to close itself. There are any number of ways to do this in IE, but nothing works in FF - the parent window remains open. Seems ridiculous that something so simple can't be done. Any help would be appreciated. Thx. I have a form that lets users click on date time value that is a link. When the link is clicked, a pop up opens up allowing the user to change the date and time. When they submit the date/time change form, the pop up is supposed to close and the date/time i the original form should be updated. This works in IE, but not FireFox. Inital form code: Code: function openTimeWin(windowURL, windowname) { var strHelpOptions = 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=320,height=230'; mywindow = window.open(windowURL, windowname,strHelpOptions); mywindow.moveTo(5,5); mywindow.focus(); } Code: <A HREF="javascript:openTimeWin('CallLoggerTime.cfm?SCDate=#URLEncodedFormat(DateFormat(StartCall,'mm/dd/yyyy'))#&ECDate=#URLEncodedFormat(DateFormat(EndDefault,'mm/dd/yyyy'))#&SCTime=#URLEncodedFormat(TimeFormat(StartCall,'h:mm:ss tt'))#&ECTime=#URLEncodedFormat(TimeFormat(EndDefault,'h:mm:ss tt'))#','TimeWin')">#TimeFormat(StartCall,"h:mm:ss tt")#</a> Pop up window relevant code: Code: <script language="Javascript"> opener.ThisForm.StartCall.value = "#newStart#"; opener.ThisForm.EndCall.value = "#newEnd#"; opener.catchdummy.prematureflag.value=0; opener.ThisForm.submit(); self.close(); </script> Anyone know what's up? Thanks! |