JavaScript - Open / Close Not Working
My code works but when I put an image in there my code doesn't work anymore.
Quote: <html> <head> <style type="text/css"> .planType{display:none; width:600px} </style> <script type="text/javascript"> <!-- function planTypeOpen(planID) { document.getElementById('info_' + planID).style.display = "block"; document.getElementById('title_' + planID).innerHTML="<a href=\"javascriptlanTypeClose('" + planID + "');\">Check this out" + "</a>"; } function planTypeClose(planID) { document.getElementById('info_' + planID).style.display = "none"; document.getElementById('title_' + planID).innerHTML="<a href=\"javascriptlanTypeOpen('" + planID + "');\">Check this out" + "</a>"; } //--> </script> </head> <body> <div id="title_1"><a href="javascriptlanTypeOpen('1');">Check this out</a></div> <div id="info_1" class="planType"> You can't see me...<br> Or Can you?? </div> </body> </html> any comments would be greatly appreciated. Similar Tutorialshello everybody I have a list like this Code: <ul id="main_menu"> <li><a href="#">Comments</a></li> <li><a href="#"> Advertising </a> <ul> <li><a href="#">edit/delete ads</a></li> <li><a href="#">Add Ads</a></li> </ul> </li> <li><a href="#">Groups</a></li> <li><a href="#">Members</a> <ul> <li><a href="#">Edit / Delete Member</a></li> <li><a href="#">Add Member</a></li> </ul> </li> <li><a href="#">Photo</a> <ul> <li><a href="#">edit / Delete Photo</a></li> <li><a href="#">Add a picture</a></li> </ul> </li> <li><a href="#">Sections</a> <ul> <li><a href="#">Edit / Delete section</a></li> <li><a href="#">Add Section</a></li> </ul> </li> <li><a href="#">General Settings</a></li> <li><a href="#">Home</a></li> </ul> This list contains lists of 8, including 4 lists contain children (Advertising , Members,Photo,Sections) And I've written this code but did not work very well Code: function MainMenu(item){ var MenuItems = document.getElementById('main_menu'); for (var i = 0; i < MenuItems.children.length; i++) { MenuItems.children[i].children[1].style.display = "none"; } item.children[1].style.display = "block"; } What i needed is when i press a list containing the submenus Close all open lists Then open this menu Hi! I need to open a window when: 1 user leaves the site 2 when the browser is closed. I tried the 'unLoad' event but it works only for the user leaves site case and not the browser close. Here is the code I tried: <html> <head> <title>Detecting browser close </title> <script type="text/javascript"> function doUnload() { myWin= open("exit_site.php", "exitWin", "width=50,height=50"); } </script> </head> <body onunload="doUnload()" <h4>Close browser!</h4> </body> </html> Neep your help, please Hello guys, im working on another little project for my team here, and the way our system works is in order to change a persons password, there is a certain link that has to be accessed...for example...if i want to change a persons password, lets say UserID: t-test100 current pass: 911 and i want to change the password to 999 instead of 911...there is a link that needs to sorta load the profile in the background first in order to do the password change, i got the password change page down to a T and it works like a charm, but ONLY when the link is accessed, so for example, this is how the link would look like https://www.***.com/Sps/jsp/MyChange...?uid=t-test100 as soon as that URL is accessed, my code that i made for the password reset, works, but if i open a fresh window (where no cookies have been logged) and i go directly to my page where i have the script to change the password, it will come back with an error, but when i go to that URL and then back to my script and run it again, it works fine....SOOOO...back to my question...how would i be able to make it so that i have an extra link on my site that i can add to go to https://www.***.com/Sps/jsp/MyChange...?uid=t-test100 URL in a new window...but i want it so that when i click the link, it opens up the URL and closes the window after 1 second...or less...just so that it loads the URL in the background and thats it basically what i need to do, just for it to open for a split second, for the browser to register that i've visited the URL for that particular username, and then so that when i try to change the password, it goes through. Hello. I'm trying to open extra information if a user clicks on a TD, and close it if he click on it again. How I can do this? All I learned to do is to show it, but I can't find something that hide it if I click on the same place. Thanks for help. __________________ הורדות Hi. I need help in adding a parenthesis in the area code of the phone number and validating it also. I made some javascript code but it is not working. Can somebody please help? I just need the code in adding () in the area code. For example: When user enter 10 digit number no spaces or dashes such as 0000000000 or 000-000-0000, I would like to have this format right away (000)000-0000. I know how to replace the characters but adding it is a tricky one for me. Can somebody please help? Thanks. Hi guys, I have read that the window.close won't work unless the window was opened through window.open. Eventhough I have the window opening through window.open method the window.close simply wont close the window. Below is my code. I appreciate you help as I am desperate to finish my project and this is the only thing between me and the closed project. I have this in the <head> in the parent window. Code: <script language="javascript"> function MM_openBrWindow(theURL,winName,features){ var left = (screen.width/2)-(800/2); var top = (screen.height/2)-(560/2); features = features + ",left=" + left; window.open(theURL,winName,features); } </script> the left and top is to center the window which is working. Then I have the below code in my button which is to open the window. Code: <input type="button" value="E-MAIL" onClick="MM_openBrWindow('email.php?camp_id=<?php echo $encrypted; ?>','','width=860,height=600'); return false"/> The $encrypted is created beforehand and the window gets opened as well. Now in the popup window... Up on submitting a form, I need the popup to close after saying 'email has been sent'. this is the code for calling the fuction Code: echo "<script language='javascript'>success();</script>"; I get the alert too. Code: function success(){ alert('E-Mail Sent Successfully'); window.close(); } I even get the alert mentioning "E-Mail Sent Successfully". But simply the window is not closed. Can you guys please shed me some light on this.... Your help is greatly appreciated Ohh and by the way I'm running FF8. Cheers E 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 suggestions welcome !!
Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. I'm implementing that stupid Cookie Law thing here in the UK, but I can't get the popup to close on click in IE. Every other browser is working fine. Any one know the fix? Code: <style type="text/css"> <!-- #eucookielaw { display:none } #note { position: fixed; z-index: 101; bottom: 0; left: 0; right: 0; background: #98FB98; text-align: center; vertical-align: middle; color: #2C2C2C; line-height: 2.5; overflow: hidden; -webkit-box-shadow: 0 0 5px black; -moz-box-shadow: 0 0 5px black; box-shadow: 0 0 5px black; } #note a { color: #2C2C2C; } #note img { vertical-align: middle; } #close { cursor: pointer; } @-webkit-keyframes slideDown { 0%, 100% { -webkit-transform: translateY(-50px); } 10%, 90% { -webkit-transform: translateY(0px); } } @-moz-keyframes slideDown { 0%, 100% { -moz-transform: translateY(-50px); } 10%, 90% { -moz-transform: translateY(0px); } } .cssanimations.csstransforms #note { -webkit-transform: translateY(-50px); -webkit-animation: slideDown 2.5s 1.0s 1 ease forwards; -moz-transform: translateY(-50px); -moz-animation: slideDown 2.5s 1.0s 1 ease forwards; } .cssanimations.csstransforms #close { display: none; } --> </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function SetCookie(c_name,value,expiredays) { var exdate=new Date() exdate.setDate(exdate.getDate()+expiredays) document.cookie=c_name+ "=" +escape(value)+";path=/"+((expiredays==null) ? "" : ";expires="+exdate.toUTCString()) } </script> <div id="eucookielaw" > <div id="note"> <img src="/images/cookie_sm.png" alt="Cookie" border="0"> This Site Uses Cookies. :: <a rel="nofollow" href="/terms.php">Learn More</a> :: <a id="close"><u>Close this Message</u> <img src="/images/close_sm.png" alt="Close" border="0"></a> </div> <script> close = document.getElementById("close"); close.addEventListener('click', function() { note = document.getElementById("note"); note.style.display = 'none'; }, false); </script> </div> <script type="text/javascript"> $("#eucookielaw").show(); SetCookie('eucookie','eucookie',365*10) </script> Example he No Claims Discount Insurance | Car, Home, Bike and Health No Claims Bonuses I am using a window.open to trigger a mailto: command. I don't want the window to stay open so I try to close it right after. The default email client launches correctly, but the window stays open and I get the following Javascript error: Unable to get value of the property 'close': object is null or undefined Code: Code: var win = window.open(mailto_link,'emailWindow'); win.close(); Can anyone tell y the below code is not working in ie7 and ie8. working fine in ie6 window opened and gets closed immediately Very Urgent: <script language="javascript"> var perlwin; perlwin=window.open("' || Hse_Constants.strFileDownloadURL || 'download.pl?strSearchSeqID_=' || numSearchSEQ || '","tinywin","resizable=0,toolbar=0,menubar=0,status=1,width=775,height=500"); function closeWin() { timer = setTimeout("checkForOpener()", 10000); } function checkForOpener(){ try{ var myVar=window.opener.document; timer = setTimeout("checkForOpener()", 10000); }catch(e){ perlwin.close(); } } closeWin();</script>' Hello I have an onclick function used in my table which opens a new window on clicking the table element.. it works fine except that I seem unable to name the window being opened... Here is my function for opening the window: Code: function LinkTo(page){ window.open ("http://www.xxx.com , "testpage" ); } Any thoughts? Thanks Hi Guys, I have written a simple code to open up a new window onclick of a button as follows; Code: function loadExamp() { var reqType = getElementValue("reqType", 1); window.open("../jsp/loadExamples.jsp?reqType=" + reqType, "Connection Test Utility - Message Examples", "width=500,height=300,menubar=no,status=yes, location=yes,toolbar=no,scrollbars=yes" ); return; } The problem is that this code is working on Google Chrome but not in Firefox and IE. Why is that and how can I resolve this issue. I am using Firefox 3.6.11 and IE 8.0.XX. Also I tried to open a new window using <a href> option with the same URL and its working but the only problem is that I want to pass my next JSP an argument which is only possible with function or script. I googled it but couldn't find much information except that there is some security problem. For that I have disabled the 'Pop up Bloker' on both Firefox and IE but still not working. When I click my button there is no activity with 'Firefox' but IE gives me error as follows; Code: Message: Invalid argument. Line: 74 Char: 2 Code: 0 URI: http://localhost:8080/T24Utility/scripts/verifyCxPool.js Please help, Thanks, -- Sjunejo Hi There, The following piece of code is working fine in IE6 but not in IE 8: if (Windowvar != null) { Windowvar.close(); } Windowvar= window.open(sUrl, 'static', viewerWinOption, true); To explain the functionality: 1. User clicks on one of the links on page 1 2. Clicking takes user from Page 1 to Page 2 (the transaction page). 3. Along with page 2, another page (Page 3) is opened. 4. User saves the transactions in the Page 2 and he is taken back to page 1 5. User clicks other link in Page 1 and activity in point 2 is repeated along with point 3 The issue is, when User clicks on the link AGAIN(for second transaction) in the Page 1 the Page 3 opens in the same browser window in the IE 6 but in IE 8 it opens in the differenct browser window (which shouldnt be happening) Any help will be appreciated. Regards, Sameer. Hi, I have long polling functionality working with Google Desktop Notifications. http://blog.perplexedlabs.com/2009/0...-long-polling/ However if I have multiple tabs open then the Notification received from the server is duplicated on every tab. Is there way to prevent this from happening as it should only appear once? Thanks Hi! 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 Hi, I want to restrict opening my popup window if it is already opened. For simple scenario, it is quite possible to do but in my case -- 1) When parent page is opening popup window, it is getting refreshed (required from client for some reason). 2) Once submit button is clicked from popup window, again parent page is getting refreshed (again its a requirement from client side). With these 2 conditions, I lost my saved value from variable and hence new popup is keep coming when the action is same. Currently I am using below code to open popup [CODE] function OpenWindow() { if(winPop && !winPop.closed) { alert("Popup is already open"); } else { winPop = window.open('MyPopupPage.aspx'); } } [CODE] Please help me to get rid of this problem. Thanks in advance. - Bhasker I do write some php, but have not much idea about JavaScript. I use window.open to open 10 pages simultaneously. I prefer to open them with a time delay from each other to put less load on the target server. This is my code with no delay. (I played around with setTimeout but can't get it to work.) PHP Code: <a href='http://www.".$new[9]."' onclick="window.open('http://www.".$new[0]."/'); window.open('http://www.".$new[1]."/'); window.open('http://www.".$new[2]."/'); window.open('http://www.".$new[3]."/'); window.open('http://www.".$new[4]."/'); window.open('http://www.".$new[5]."/'); window.open('http://www.".$new[6]."/'); window.open('http://www.".$new[7]."/'); window.open('http://www.".$new[8]."/')\" target='new300/'>Open 10</a> how to close a tab in html or javascript
|